Same name and namespace in other branches
  1. 4.6.x modules/user.module \user_register()
  2. 5.x modules/user/user.module \user_register()
  3. 6.x modules/user/user.module \user_register()
3 string references to 'user_register'
user_configure in modules/user.module
user_menu in modules/user.module
Implementation of hook_menu().
user_register_submit in modules/user.module

File

modules/user.module, line 1167
Enables the user registration and login system.

Code

function user_register() {
  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);
  }

  // Display the registration form.
  if (!$admin) {
    $form['user_registration_help'] = array(
      '#type' => 'markup',
      '#value' => filter_xss_admin(variable_get('user_registration_help', '')),
    );
  }
  $affiliates = user_auth_help_links();
  if (!$admin && count($affiliates) > 0) {
    $affiliates = implode(', ', $affiliates);
    $form['affiliates'] = array(
      '#type' => 'markup',
      '#value' => '<p>' . t('Note: if you have an account with one of our affiliates (%s), you may <a href="%login_uri">login now</a> instead of registering.', array(
        '%s' => $affiliates,
        '%login_uri' => url('user'),
      )) . '</p>',
    );
  }
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Username'),
    '#size' => 30,
    '#maxlength' => 60,
    '#description' => t('Your full name or your preferred username; only letters, numbers and spaces are allowed.'),
    '#required' => TRUE,
  );
  $form['mail'] = array(
    '#type' => 'textfield',
    '#title' => t('E-mail address'),
    '#size' => 30,
    '#maxlength' => 64,
    '#description' => t('A password and instructions will be sent to this e-mail address, so make sure it is accurate.'),
    '#required' => TRUE,
  );
  if ($admin) {
    $form['pass'] = array(
      '#type' => 'password',
      '#title' => t('Password'),
      '#size' => 30,
      '#description' => t('Provide a password for the new account.'),
      '#required' => TRUE,
    );
    $form['notify'] = array(
      '#type' => 'checkbox',
      '#title' => t('Notify user of new account'),
    );
  }
  $extra = _user_forms($null, $null, $null, 'register');

  // Only display form_group around default fields if there are other groups.
  if ($extra) {
    $form['account'] = array(
      '#type' => 'fieldset',
      '#title' => t('Account information'),
    );
    $form['account']['name'] = $form['name'];
    $form['account']['mail'] = $form['mail'];
    $form['account']['pass'] = $form['pass'];
    $form['account']['notify'] = $form['notify'];
    unset($form['name'], $form['mail'], $form['pass'], $form['notify']);
    $form = array_merge($form, $extra);
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Create new account'),
    '#weight' => 30,
  );
  return drupal_get_form('user_register', $form);
}