user_register

Versions
4.6
user_register($edit = array())
4.7 – 6
user_register()

Code

modules/user.module, line 1167

<?php
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);
}
?>
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.