0

I'm attempting to make a simple login page on the front page that once you log in it will route you to your profile. This part I got working with Rules, but if the user clicks the home link on the site at any point, when logged in, I want to route the user to the profile, not the front page.

I tried a similar trigger to the one I got routing a user when they log in. This being on page view trigger when role is not anonymous and URL alias is /node route to user/[account:uid]

When logged in I click the home button and it's not getting triggered. It just sends me to the homepage.

How can I do this with Rules?

1 Answer 1

1

It sounds like there's some missing detail (e.g. checking the right alias, token data not available, etc.).

A simple way to do this to do a page redirect action on a Drupal is initializing event with conditions, Data comparison on [site:current-page:path] & negated User has role(s) on [site:current-user]. Then you can check for the Drupal path that's set for your front page (i.e. '/node').

For example:

{ "rules_login_frontpage_redirect" : { "LABEL" : "Logged in Frontpage Redirect to Profile Page", "PLUGIN" : "reaction rule", "OWNER" : "rules", "REQUIRES" : [ "rules" ], "ON" : { "init" : [] }, "IF" : [ { "NOT user_has_role" : { "account" : [ "site:current-user" ], "roles" : { "value" : { "1" : "1" } } } }, { "data_is" : { "data" : [ "site:current-page:path" ], "value" : "node" } } ], "DO" : [ { "redirect" : { "url" : "user\/[site:current-user:uid]" } } ] } } 
3
  • Do you have a page that explains in detail about this example you have? I just want to know how this works so I can build more complex rules as needed. Commented Jul 23, 2016 at 18:35
  • This example looks to work but I don't understand why it works. Commented Jul 23, 2016 at 18:38
  • 1
    The rule says, IF: the internal requested path is /node & the user isn't anonymous on boot up THEN: redirect the current user page, Note, that setting an alias, & setting a path as the front page are two different things. This rule works because /node is set as the default home page. The actual rule path would need to change if it was set to something different. Commented Jul 23, 2016 at 19:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.