I am trying to redirect user to edit profile page after accessing the password reset link, code looks like
function mymodule_reset_menu_alter(&$items) { // Drupal's default behavior is to show the user a log-in form before // their user profile. We replace this item to skip the uneccesary step. $items['user/reset/%/%/%'] = array( 'title' => 'Account settings', 'access callback' => 'simple_pass_reset_pass_reset_access', 'access arguments' => array(2, 3, 4), 'page callback' => 'test', 'page arguments' => array(2, 3, 4), 'type' => MENU_CALLBACK, ); } function test($uid, $timestamp, $hashed_pass, $option = NULL) { global $user; // Show the user edit form instead of silly one-time login form. $account = user_load($uid); $user = $account; $token = drupal_random_key(); $_SESSION['pass_reset_' . $user->uid] = $token; drupal_goto('user/' . $user->uid . '/edit', array('query' => array('pass-reset-token' => $token))); }
while test() is callback for menu ‘user/reset/%/%/%’.
The issue is when the user access the link for first time user gets “Access Denied” for second time user successfully redirects to edit profile page with password reset option. I think issue must be in the way the token is generated as it is the only thing which changes, but have no clue on how to fix this.