1 user.pages.inc user_pass()

Form builder; request a password reset.

See also

user_pass_validate()

user_pass_submit()

Related topics

File

core/modules/user/user.pages.inc, line 42
User page callback file for the user module.

Code

function user_pass() {
  global $user;

  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Username or email address'),
    '#size' => 60,
    '#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH),
    '#required' => TRUE,
    '#default_value' => isset($_GET['name']) ? $_GET['name'] : '',
    '#attributes' => array(
      // Add attributes to field to prevent spell-jacking and unwanted
      // automatic changes caused by the browser.
      'autocapitalize' => 'none',
      'autocorrect' => 'off',
      'spellcheck' => 'false',
    ),
  );

  // Allow logged in users to request this also.
  if ($user->uid > 0) {
    $form['name']['#type'] = 'value';
    $form['name']['#value'] = $user->mail;
    $form['mail'] = array(
      '#prefix' => '<p>',
      '#markup' => t('Password reset instructions will be mailed to %email. You must log out to use the password reset link in the email.', array('%email' => $user->mail)),
      '#suffix' => '</p>',
    );
  }
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Reset password'));

  return $form;
}