Further to this previous question, https://drupal.stackexchange.com/questions/1790/redirect-users-after-login-depending-on-the-users-roles I am trying to accomplish a similar redirect on a D7 whereby once a user with a specific role type has logged in, they are redirected to a homebox (using the Homebox module) page of 1 of 2 types (1 Teacher; 2 Student) and the homeboxes nodes are named accordingly: 1) teacherhomebox, 2) studenthomebox using URL aliases. I have been following Johan Falks tutorial http://vimeo.com/28804544 (many times now!) and thought I understood what appears to be a simple task, but after testing either of the said roles, my redirects do not show the relevant (after login) user homebox as the primary page and simply stays on my custom Panel 'landingpage' I have setup as the primary welcome site homepage. Of course they do log in and it shows their account link on the header (which I'll remove later) I'm not sure what or why the redirects are not working, maybe I've not put the correct account select in the Rules UI but FYI and for testing purposes (using a student role) the setup is as such:

Event: User has logged in

Condition: User has role(s) (parameter: Role= student, match=ANY)

Actions: Element: Page Redirect (parameter: URL: studenthomebox)

I have in the URL redirect Value, put "studenthomebox"

I would also like to add that I am trying to create a 'homebox' dashboard as per drupal.org and would be happy to acheive the same along with using the Rules module (with homebox) and would prefer to stay using Rules given the option.

Any help is very much appreciated as I'm after many hours, rather confused now.

  • It's possible this never worked as I was adding conditions within the loop and not as a Component as detailed here: drupal.org/node/1300058
    – Paul B
    Feb 20, 2013 at 15:27

2 Answers 2


Check that you are not using any other contrib modules like Login Toboggan which may be setting a redirect after log in.

Failing that, turn on Rules Debugging by going to admin/config/workflow/rules/settings and ticking the 'Log debug information to the system log' checkbox.

Log out and log back into your site as a student user. Then go to admin/reports/dblog and check the debugging messages set by Rules.

You will then be able to see which of your conditions is failing.

  • Thanks KidRobot for your reply. I'm not using Toboggan nor any other redirect. Debug shows that it seems okRules debug information: "Reacting on event User has logged in. 0 ms Reacting on event User has logged in. 103.162 ms Evaluating conditions of rule User Login Redirect To Home Dashboard. edit 103.203 ms OR evaluated to FALSE. 103.225 ms AND evaluated to FALSE. 103.273 ms Finished reacting on event User has logged in.)
    – Paul B
    Sep 2, 2012 at 12:50
  • Damn edit timeout!! LOL ....the frontpage has a Panels for the 'landing homepage'. Once the user logs in, then this landing page should be replaced with the user dashboard (based on a role as their are a DB for each role: student, teacher; Simple enough). In the Rules UI, I put in the value for the URL of the node alias for the relevant Rule: 'studenthomebox' in this case. For FYI, I'm running at home compbox on localhost on a pure Ubuntu 10.xx LAMP box running D7.14 with all modules upto date.
    – Paul B
    Sep 2, 2012 at 12:58

Solution if no other redirect facilities are enabled

Here is the rule (in Rules import format) that will redirect a user with the role that matches "role id = 5" to the page teacherhomebox:

{ "rules_redirect_role_id5_to_selected_page" : {
    "LABEL" : "Redirect role ID5 to selected page",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_login" : [] },
    "IF" : [
      { "user_has_role" : { "account" : [ "account" ], "roles" : { "value" : { "5" : "5" } } } }
    "DO" : [ { "redirect" : { "url" : "teacherhomebox" } } ]

Just import the above rule and adapt the value (=5) of the role id to fit your role for "Teacher". With that you solved your question for roles with role ID = 5.

To also make it work for other values of role ID, and because of the fact that a Rules action cannot contain "conditions", you basically have 2 possible approaches:

  • Create a similar rule for each possible value of role ID.
  • Use the Conditional Rules module to enhance the Rules Action in the above rule to alter the flow, using either Conditional (if/else) of Switch logic.

Solution if other redirect facilities are enabled

The rule above should solve your question, unless some other module also does a redirect after login. If you have other redirect-logic enabled, then try to experiment with a rule using Rules Event "Drupal is initializing", combined with a Rules Condition that checks the "current path". For an example of such rule, refer to the answer to "How to make the permissions of a module more granular?".

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.