You are here

function user_pass_submit in Drupal 5

Same name and namespace in other branches
  1. 4 modules/user.module \user_pass_submit()
  2. 6 modules/user/user.pages.inc \user_pass_submit()
  3. 7 modules/user/user.pages.inc \user_pass_submit()

File

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

Code

function user_pass_submit($form_id, $form_values) {
  global $base_url;
  $account = $form_values['account'];
  $from = variable_get('site_mail', ini_get('sendmail_from'));

  // Mail one time login URL and instructions.
  $variables = array(
    '!username' => $account->name,
    '!site' => variable_get('site_name', 'Drupal'),
    '!login_url' => user_pass_reset_url($account),
    '!uri' => $base_url,
    '!uri_brief' => preg_replace('!^https?://!', '', $base_url),
    '!mailto' => $account->mail,
    '!date' => format_date(time()),
    '!login_uri' => url('user', NULL, NULL, TRUE),
    '!edit_uri' => url('user/' . $account->uid . '/edit', NULL, NULL, TRUE),
  );
  $subject = _user_mail_text('pass_subject', $variables);
  $body = _user_mail_text('pass_body', $variables);
  $mail_success = drupal_mail('user-pass', $account->mail, $subject, $body, $from);
  if ($mail_success) {
    watchdog('user', t('Password reset instructions mailed to %name at %email.', array(
      '%name' => $account->name,
      '%email' => $account->mail,
    )));
    drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
  }
  else {
    watchdog('user', t('Error mailing password reset instructions to %name at %email.', array(
      '%name' => $account->name,
      '%email' => $account->mail,
    )), WATCHDOG_ERROR);
    drupal_set_message(t('Unable to send mail. Please contact the site admin.'));
  }
  return 'user';
}