user_register_form

Versions
7
user_register_form($form, &$form_state)

Form builder; the user registration form.

See also

user_account_form()

@see user_account_form_validate()

See also

user_account_form_submit()

@see user_register_submit()

Related topics

Code

modules/user/user.module, line 3093

<?php
function user_register_form($form, &$form_state) {
  global $user;

  $admin = user_access('administer users');

  // If we aren't admin but already logged on, go to the user page instead.
  if (!$admin && $user->uid) {
    drupal_goto('user/' . $user->uid);
  }

  $form['#user'] = drupal_anonymous_user();
  $form['#user_category'] = 'register';

  $form['#attached']['library'][] = array('system', 'cookie');
  $form['#attributes']['class'][] = 'user-info-from-cookie';

  // Start with the default user account fields.
  user_account_form($form, $form_state);

  if ($admin) {
    // Redirect back to page which initiated the create request;
    // usually admin/people/create.
    $form_state['redirect'] = $_GET['q'];
  }

  // If the "account" fieldset is the only element at the top level, its
  // borders are hidden for aesthetic reasons. We do not remove the fieldset but
  // preserve the form structure so that modules implementing
  // hook_form_FORM_ID_alter() know where to find the basic elements.
  if (count(element_children($form)) == 1) {
    $form['account']['#type'] = 'markup';
  }

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Create new account'),
    '#weight' => 30,
  );

  // Add the final user registration form submit handler.
  $form['#submit'][] = 'user_register_submit';

  return $form;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.