简体   繁体   中英

How do I change the reset password text in Drupal 7 (one-time login)

How do I change the text on the one-time login page for Drupal 7.

"This is a one-time login for user and will expire on date.

Click on this button to log in to the site and change your password.

This login can be used only once."

If you need to change the text on the password reset page, not just in the e-mail, that has to be done via a theme function. There's a page on how to do it (for both D6 and D7) in the Theming Guide on Drupal.org: https://drupal.org/node/350634

It also covers the user login and registration pages. Note that in sample code provided for D7 in Steps 2 & 3, they've left out the function for the password reset page, but you can create a function for that following the same pattern they use for the other two.

Specifically...

In template.php in your custom theme, create this function:

<?php
/**
 * Implements hook_form_FORM_ID_alter()
 *
 * Set custom text on the user password reset form.
 */
function YOUR_THEME_form_user_pass_reset_alter(&$form, &$form_state, $form_id) {
  $form['message']['#markup'] = "<p>Your custom text goes here.</p>";
  $form['help']['#markup'] = "<p>This is another line of custom text.</p>";

  // If you prefer, you can just delete the second line of markup with:
  // unset($form['help']);
}

This can be found at the Interface Translation in your settings.

This way you can replace the strings with your own text without having to hook anything.

This page is a Drupal form, just make use of hook_form_alter. The form id is "user_pass_reset".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM