質問

In Drupal 7 there is a way to reset your password by going to '/user/password'. If you fill in your email address you should get an email in your inbox with an url to reset your password.

On that page you need to click 'login' and you get redirected to your profile page ('/user'). Is there maybe a way to edit this last redirect?

Thanks!

役に立ちましたか?

解決

You can change the content of the email sent to the user in admin/config/people/accounts.

screenshot

The default content is the following one:

[user:name],

A request to reset the password for your account has been made at [site:name].

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. It expires after one day and nothing will happen if it's not used.

-- [site:name] team

If you are going to change the URL to which the user is directed, you need to write all the code to handle the password recovery request.

To have an idea of what Drupal does to handle a request of password reset, see user_pass_reset().

他のヒント

I suppose it's better to look at user_pass_submit(). It makes

$form_state['redirect'] = 'user';

and redirects to /user page.

To make redirect to 'user/login' (for example) you have to add form alter hook and add one more submit callback:

/**
 * Implements hook_form_alter().
 *
 *
 */
function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ('user_pass' == $form_id) {
    $form['#submit'][] = '_password_recover_submit';
  }
}

function _password_recover_submit($form, &$form_state){
  $form_state['redirect'] = 'user/login';
}

This solution works for me.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top