I need to send users to the user/me/edit page to change their password when they log in the first time and also in cases of password reset. The rest of the time they need to go to an internal dashboard page.

What is the best combination or single module to accomplish this? I've tried numerous combinations of login destination and login toboggan as well as each on it's own but can't get it right.

Both my register and login forms are on my homepage.


I think the first code snippet on this post is what you are looking for:


function mymodule_user($op,&$edit,&$account,$category = NULL){  
    if($op == 'login'){
        if($account->login == 0){ // check the last login  
        //do stuff here  


It uses hook_user() to check the user's last login time. If it's 0, meaning she haven't logged in before, you can redirect the user with a function like drupal_goto.

You'll have to create a simple custom module and place your code in mymodule.module file.

If you are not comfortable writing a module for this, you can try creating a rule with the Rules module, I haven't been able to test this approach, but here are the basics:

Create a new rule:

  1. Event: 'User has logged in'
  2. Condition: 'Data comparison' - check the data called 'site:current-user:last-login' or 'account:last-login' for last login information.
  3. Action:'Page redirect'
| improve this answer | |

To make users to change their password on first time login you can use Password policy module. Just download and enable this module and goto 'admin/config/people/password_policy/password_change' page to configure force password change options.

And for redirecting users of different role to different page you can use Login Destination module. Login destination settings can be configured from 'admin/config/people/login-destination' page.

| improve this answer | |

This is the behavior I experienced:

  • User would create account and would copy & paste link onto homepage they already had open. (it worked fine if they clicked on the link in the email but you have to address multiple login scenarios)
  • Would log in and stay stuck on the homepage without any navigation

What I ended up doing:

  1. downloaded user_stats module and wrote the rule with truth value code:
    return (user_stats_get_stats('login_count', $account->uid) == 1) ? ’1′ : ”; with redirect to user/me/edit
  2. login destination module to redirect from user/me/edit to user/me/personal_dashboard (internal page). I had to do this because as soon as the user saved the password, they would go to the homepage due to the fact that the link had a destination parameter -> user/me/edit?destination=homepage I had to override.
  3. in order to force re-direction to the user/me/personal_dashboard on all subsequent logins, I wrote this rule with php code: If ([account:user-last-login-raw]) { return TRUE; } else { return FALSE; }

This works. I couldn't get login toboggan to route to the right place and login destination doesn't allow for more than one case.

Thank you to those above for their input. I read this too late to try the password policy module but I'll check it out.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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