Drupal Rules + One-Time Forwarding

The problem is this:

I have a rule that redirects users to the landing page after logging in. It works great.

However, if the user forgets his password, they will be sent a link to the one-time login page. They click a button and (due to my rule) go to their landing page.

Of course, the problem is that they cannot change their password, because in order to change the password normally (in the user profile) you need to know your password in order to change it.

So, how do I change the redirection rule to say:

"Redirect to the landing page if the login user is not logged in to the single sign-on screen" or "Redirect to the landing page if the destination URL does not start with / user / reset / * (can you wildcard?)"

Thanks in advance for any advice.

+4
source share
5 answers

You can do this with this rule:

{ "rules_after_login_redirect_to_news" : { "LABEL" : "After login redirect to news.", "PLUGIN" : "reaction rule", "WEIGHT" : "0", "REQUIRES" : [ "rules" ], "ON" : [ "user_login" ], "IF" : [ { "NOT text_matches" : { "text" : [ "site:current-page:path" ], "match" : "^user\/reset\/", "operation" : "regex" } } ], "DO" : [ { "redirect" : { "url" : "news" } } ] } } 
+3
source

In the project I'm currently working on, I ran into the same problem. We solved this using the Context module ( http://drupal.org/project/context ).

Install and enable the Context module. Create a context with the condition: path = ~ user / reset / * (Leave the responses blank)

Use this context as a condition in a name forwarding rule (Context Rules / - a set of contexts)

+2
source

I fixed this problem only with the rules, as described in another answer here, but I had to change it to work, I had to set the condition for comparing the text to negative, and redirect the page to force redirection and the page that I wanted was called "getting started" " Works perfect

So, the rule I added: EVENTS User logged in

CONDITIONS NOT text comparison Parameter: Text: [site: current page: path], corresponding text: user, comparison operation: starts with

Actions Page redirection Parameter: URL: receive-start

+2
source

You can also fix this problem only with the help of module rules, without coding.

In my case, I wanted to redirect people to my workplace after entering the system. But people who have forgotten their password will also be redirected to their desktop and will not be able to change their password. They had to go to their profile page, but again they had to re-enter the password: peer-to-peer registration no longer worked.

So this is the rule I added:

Events Event: User logged in.

Conditions Elements: text comparison. Parameter: Tekst: [site: current-page: path], Corresponding text: user, Comparison operation: ends with

Actions Elements: page redirection Parameter: URL: admin / workbench, Force redirect: false

+1
source

There is a route rule module and Rules bonus rule module that can do this well in Drupal 6. But, unfortunately, this feature / module does not seem to be suitable for Drupal 7. See http://drupal.org/node/1506298 and http://drupal.org/node/1045964#comment-6016904

However, you can still use the PHP condition to check the path. Try this (add a new condition and use php to add this. You will need a php module). In the Rules that redirect users after logging in,

 <?php if (arg(0) == 'user' && arg(1) == 'reset'){ return FALSE; } else{ return TRUE; } ?> 

This will prevent the rule from continuing if the path is us user / reset / *. In addition, you may need the same condition when TRUE False is exchanged in another rule that redirects users to a password change.

0
source

All Articles