I created password reset link using user_pass_reset_url function. This is redirecting to user/uid/edit page after click login.

How to redirect on custom url?

3 Answers 3


Since the form builder for user/reset/%/%/% (user_pass_reset()) is using the following code to redirect the user, you can only replace the form builder with one that redirects the users where you want.

      $token = drupal_hash_base64(drupal_random_bytes(55));
      $_SESSION['pass_reset_' . $user->uid] = $token;
      drupal_goto('user/' . $user->uid . '/edit', array('query' => array('pass-reset-token' => $token)));

If you do that (which means implementing hook_menu_alter()), be careful of how the workflow is modified. If you need to change that radically, and you want to be sure not to introduce security risks, I would rather:

  • Alter the URL returned from user_pass_reset_url(), so that users are redirected to your page
  • Implement a form builder for your page using the code used by user_pass_reset() as guideline

Done using Custom code drupal_goto. I checked the current path and redirect it using drupal_goto. So whenever the user go to user/edit link he will be redirected.


You can use hook_drupal_goto_alter to customize the current user password reset URL, e.g.

 * Implements hook_drupal_goto_alter().
function MYMODULE_drupal_goto_alter(&$path, &$options, &$http_response_code) {
  if (module_exists('token') && arg(0) == 'user' && arg(1) == 'reset') {
    $path = user_pass_reset_url();

Where user_pass_reset_url() is your custom function providing new URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.