I have a website where some users will be registered by our employees and will not have emails associated with them. I would like to keep the email field in the required field, so I developed a random email generator.
function generateRandomEmail() {
$email = 'noemail'. rand(0,1000000) . '@noemail.com';
return $email;
}
So, I attached this to the user register form, and it worked perfectly, efficiently generating email for these users.
However, at the same time, all other fields associated with the main account section (password, username, notification, etc.) disappeared. My question is: is there a quick way to fill in the remaining fields that I do not want to change? I used drupal_render ($ form); in tpl.php, but it did not work in alter form.
This is where I change the form:
function accountselect_user($op, &$edit, &$account, $category) {
if ($op == 'register') {
$fields['account']['mail'] = array(
'#type' => 'textfield',
'#default_value' => generateRandomEmail(),
);