function user_mail_tokens in Drupal 10
Same name and namespace in other branches
- 8 core/modules/user/user.module \user_mail_tokens()
- 6 modules/user/user.module \user_mail_tokens()
- 7 modules/user/user.module \user_mail_tokens()
- 9 core/modules/user/user.module \user_mail_tokens()
Token callback to add unsafe tokens for user mails.
This function is used by \Drupal\Core\Utility\Token::replace() to set up some additional tokens that can be used in email messages generated by user_mail().
Parameters
array $replacements: An associative array variable containing mappings from token names to values (for use with strtr()).
array $data: An associative array of token replacement values. If the 'user' element exists, it must contain a user account object with the following properties:
- login: The UNIX timestamp of the user's last login.
- pass: The hashed account login password.
array $options: A keyed array of settings and flags to control the token replacement process. See \Drupal\Core\Utility\Token::replace().
2 string references to 'user_mail_tokens'
- UserTokenReplaceTest::testUserTokenReplacement in core/
modules/ user/ tests/ src/ Functional/ UserTokenReplaceTest.php - Creates a user, then tests the tokens generated from it.
- user_mail in core/
modules/ user/ user.module - Implements hook_mail().
File
- core/
modules/ user/ user.module, line 798 - Enables the user registration and login system.
Code
function user_mail_tokens(&$replacements, $data, $options) {
if (isset($data['user'])) {
$replacements['[user:one-time-login-url]'] = user_pass_reset_url($data['user'], $options);
$replacements['[user:cancel-url]'] = user_cancel_url($data['user'], $options);
}
}