Problem/Motivation

Several tokens can be used in the e-mail messages configured on /admin/config/people/accounts, but it is not clear what each token represents.

Steps to reproduce

Visit /admin/config/people/accounts as a site administrator, and scroll down to the Emails section. Each vertical tab includes the text,

Available variables are: [site:name], [site:url], [user:display-name], [user:account-name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:mail-change-url], [user:cancel-url].

Proposed resolution

To be determined (TBD).

Perhaps we should expand the help text.

Perhaps, instead of repeating the help text in each vertical tab, we should move it to a separate section.

Remaining tasks

User interface changes

TBD

API changes

None

Data model changes

None

Release notes snippet

TBD

Original report by [joachim]

  $email_token_help = t('Available variables are:') . ' !username, !site, !password, !uri, !uri_brief, !mailto, !date, !login_uri, !edit_uri, !login_url, !cancel_url.';

The above message is shown to the admin user without any explanation of what the tokens mean. I can guess at some of them, but what is !uri_brief for instance? Or !mailto?

Comments

derjochenmeyer’s picture

Status: Active » Needs review

This seems to be old code from user.admin.inc (part of the user module). The current code/text is more descriptive, so this seems fixed?

Current code:

  // These email tokens are shared for all settings, so just define
  // the list once to help ensure they stay in sync.
  $email_token_help = t('You can use the following tokens in your e-mail message text: !site-name-token, !site-url-token, !user-name-token, !user-mail-token, !site-login-url-token, !user-edit-url-token, !user-one-time-login-url-token, !user-cancel-url-token', array('!site-name-token' => '[site:name]', '!site-url-token' => '[site:url]', '!user-name-token' => '[user:name]', '!user-mail-token' => '[user:mail]', '!site-login-url-token' => '[site:login-url]', '!user-edit-url-token' => '[user:edit-url]', '!user-one-time-login-url-token' => '[user:one-time-login-url]', '!user-cancel-url-token' => '[user:cancel-url]'));
joachim’s picture

Status: Needs review » Active

Faced with that, I still wouldn't know which of [user:one-time-login-url] and [site:login-url] to use.

derjochenmeyer’s picture

Status: Active » Needs review

True for new users/admins, but the interface gives you example usage, so I still think there is enough clarifying information here:

[user:name],

A site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser:

[user:one-time-login-url]

This link can only be used once to log in and will lead you to a page where you can set your password.

After setting your password, you will be able to log in at [site:login-url] in the future using:

username: [user:name]
password: Your password

--  [site:name] team
retester2010’s picture

Status: Needs review » Active

no patch here, so active

scotwith1t’s picture

never paid close enough attention, but i found myself wondering this today as well! the !mailto token i found to be the email for the person who is registering. i definitely second the idea of clearer description of each token on the registration settings page. i went ahead and figured out what they all are just in case anyone comes across this one:

Tokens are:
!username - requested username during registration process
!site - Site name from Site Configuration page
!password - temporary pwd selected by system or the chosen password by the user
!uri - uri to site (including http://)
!uri_brief - uri to site (without http://)
!mailto - email of user registering
!date - registration date (Medium format)
!login_uri - link to /user page
!edit_uri - link to /user/[uid]/edit page
!login_url - one-time use link for logging in

5t4rdu5t’s picture

Useful post, scot.self. Thank you.

benjifisher’s picture

Title: user email settings: explain that the tokens mean » user email settings: explain what the tokens mean
Version: 7.x-dev » 9.4.x-dev
Issue summary: View changes

Not much has changed since this issue was created.

I think the policy is still that bugs have to be fixed in the current version of Drupal before they are fixed in an older one, so I am changing the target branch to 9.4.x. I am also updating the issue summary.

The code snippet is now in Drupal\user\AccountSettingsForm::buildForm():

    $email_token_help = $this->t('Available variables are: [site:name], [site:url], [user:display-name], [user:account-name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:mail-change-url], [user:cancel-url].');

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pameeela’s picture

Category: Bug report » Task
Issue tags: +Bug Smash Initiative

Changing this to a task because I think it would just be an improvement. Since the OP, the token format has changed and I think it is much more clear what they all mean.

pameeela’s picture

Title: user email settings: explain what the tokens mean » Provide an explanation of user email settings tokens

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.