function user_pass_reset_url

Generates a unique URL for a user to login and reset their password.

Parameters

object $account: An object containing the user account.

array $options: (optional) A keyed array of settings. Supported options are:

  • langcode: A language code to be used when generating locale-sensitive URLs. If langcode is NULL the users preferred language is used.

Return value

A unique URL that provides a one-time log in for the user, from which they can change their password.

2 calls to user_pass_reset_url()
UserTokenReplaceTest::testUserTokenReplacement in drupal/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
Creates a user, then tests the tokens generated from it.
user_mail_tokens in drupal/core/modules/user/user.module
Token callback to add unsafe tokens for user mails.

File

drupal/core/modules/user/user.module, line 1743
Enables the user registration and login system.

Code

function user_pass_reset_url($account, $options = array()) {
  $timestamp = REQUEST_TIME;
  $langcode = isset($options['langcode']) ? $options['langcode'] : user_preferred_langcode($account);
  $url_options = array(
    'absolute' => TRUE,
    'language' => language_load($langcode),
  );
  return url("user/reset/{$account->uid}/{$timestamp}/" . user_pass_rehash($account->pass, $timestamp, $account->login), $url_options);
}