title: Hooking user registration in Drupal
body: <p>I have a site where some users will be registered by our staff, and won't have emails associated with them. I would like to keep the email field a required field, so I devised a random email generator.</p>
  
  <pre><code> function generateRandomEmail() {
       $email = 'noemail'. rand(0,1000000) . '@noemail.com';
       return $email;
    }
  </code></pre>
  
  <p>So, I attached that to the user register form alter, and it worked nicely, effectively generating an email for these users.</p>
  
  <p>However, in the process, all the other fields associated with the main account section (password, username, notify, etc.) disappeared. My question, is there a quick way to populate the rest of the fields that I don't want to alter? I've used drupal_render($form); in a tpl.php, but it didn't work in the form alter.</p>
  
  <p>Here is where I'm altering the form:</p>
  
  <pre><code>  function accountselect_user($op, &amp;$edit, &amp;$account, $category) {
      if ($op == 'register') {
  
         $fields['account']['mail'] = array(
         '#type' =&gt; 'textfield',
         '#default_value' =&gt; generateRandomEmail(),
      );
  </code></pre>