function user_registrationpassword_confirmation_url in User registration password 8
Same name and namespace in other branches
- 6 user_registrationpassword.module \user_registrationpassword_confirmation_url()
- 7 user_registrationpassword.module \user_registrationpassword_confirmation_url()
Generates a unique URL for a user to login with their password already set.
Parameters
\Drupal\user\UserInterface $account: 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
string A unique URL that provides a one-time log in for the user, from which they can change their password.
See also
user_registrationpassword_mail_tokens()
2 calls to user_registrationpassword_confirmation_url()
- user_registrationpassword_mail_tokens in ./user_registrationpassword.module 
- Token callback to add unsafe tokens for user mails.
- user_registrationpassword_tokens in ./user_registrationpassword.tokens.inc 
- Implements hook_tokens().
File
- ./user_registrationpassword.module, line 368 
- Enables password creation on registration form.
Code
function user_registrationpassword_confirmation_url(UserInterface $account, array $options = []) {
  $timestamp = \Drupal::time()
    ->getRequestTime();
  $langcode = isset($options['langcode']) ? $options['langcode'] : $account
    ->getPreferredLangcode();
  return \Drupal::service('url_generator')
    ->generateFromRoute('user_registrationpassword.confirm', [
    'uid' => $account
      ->id(),
    'timestamp' => $timestamp,
    'hash' => user_pass_rehash($account, $timestamp),
  ], [
    'absolute' => TRUE,
    'language' => \Drupal::languageManager()
      ->getLanguage($langcode),
  ]);
}