In Drupal 7, the Rules module was quite simple to use. You create a rule, define it's action and done. In Drupal 8 version of Rules however, i.e the alfa1 version (which is what I'm using), I see some weird behavior.

I am not able to use tokens in data selectors (also autocomplete won't work).

What I want to accomplish: I have two roles: admin and non-admin.

When a user assigned with the role as admin log in, he should be redirected to his dashboard (url: /admin/dashboard) When a user assigned with the role of non-admin, he should be redirected to his particular page (url: /non-admin/dashboard)

There are 2 Rules Conditions related to User Roles:

  • one is under "Others" tab (= User Role).
  • one is under "User" tab (= User has role(s)).

Both are shown in the image below:

enter image description here

When I choose the 2nd one, I always get an php error (issue already posted on Rules on that).

When I choose the 1st one, no matter what I pass in the Rules Condition, it always returns true and performs the Rules Action.

enter image description here

Am I missing something?

  • The rules UI is not feature complete yet, and the rules module is in alpha.
    – mradcliffe
    Commented Jul 11, 2016 at 11:40
  • I am using "Other Releases" of Rules. Is there any other way I could accomplish my task without much of a messing. Commented Jul 11, 2016 at 11:43
  • The way to accomplish redirection of users on login based on role is to code with hook_user_login() in a custom module. Other modules such as logintoboggan or login_redirect are also not available for Drupal 8.
    – mradcliffe
    Commented Jul 11, 2016 at 11:46
  • I think hooks are depreciated. aren't they? Commented Jul 11, 2016 at 11:47
  • 1
    The Rules module for D8 only has an alfa1 version. I hesitate to post that as a real answer, but it could well be the explanation of the behaviour you described in your question. Let me know if you want me to convert this comment to an actual answer. Commented Jul 11, 2016 at 13:57

1 Answer 1


Note: This is not an accurate answer of this problem, as by this time, the Rules module is still in development. This is what I did to solve my problem:

Download PHP Module, as it is removed from Drupal core and is a contrib module now. In Rules, create a new condition known as "PHP execute" and write a php segment which checks user role.

This is probably the easiest way around this problem and will work fine if you are trying to fiddle around. But for production site, I won't recommend this.

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.