Download & Extend

Rules redirect on login, adding conditional php to recognize one-time login and password reset

Project:Rules
Version:6.x-1.x-dev
Component:Rules Engine
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

add a condition for your redirect rule, with a php-evaluation that checks the path.

Comments

#1

Subscribe

#2

Version:6.x-1.0-rc2» 6.x-1.x-dev

Perhaps we could add an event to an event when "user" requests new password. Since they wouldn't be logged in when this happens, it would have to be based on the submitted user name. This way, you could add the user to another role that tracks their status in your registration workflow.

Would this do the trick?

#3

This can probably work I can assign another role to the user and then check if that role exists before doing a redirect on login. It should also apply to the users email because I use loggin toboggan and require users to login with email addresses instead of user names.

#4

I am having the same issue.

My website requires users to be approved. When the user clicks on the one-time login link and is asked to change their password, they are giving a message at the top of the content body to go fill out their profile (per my rule which is triggered on login).

Another solution for me would be to show the message on a particular page but only once a day -- not every time the user visits the page.

#5

I had the same issue, and searched for an answer for a while (even trying other modules for redirecting on logon). Finally I found this solution that works for Rules.
What you do is add a condition for your redirect rule, with the following php-evaluation:

if (arg(0) == 'user' && arg(1) == 'reset') {
return false;
} else {
return true;
}

This checks if the user is using a one-time password, if that is the case the redirect rule is not triggered.
Hope this helps!

#6

Brilliant! Thanks for the tip!

#7

Great thank you so much!

#8

@BlackD Thanks for the tip in #5, works great.

#9

Title:Forget Password link triggers login rule, login rule confuses user by taking them to the wrong screen» Rules redirect on login, adding conditional php to recognize one-time login and password reset

I hope no-one minds me changing the title of this issue. I think this might help people find what they might be looking for.

Izzy

#10

I just wanted to thank BlackD for the tip in #5, exactly what I was looking for!

#11

Wow! Thanks, BlackD.

My users were being re-directed to a role-specific home page when they used the one-time login, so they could never set or change their password. Your snippet saved me! Thanks so much!!! (FYI, it works in Drupal 7, as well.)

#12

#5 does not work for me.
I was unable to find a doc on how URL arguments are passed, e.g.
- should arguements above not be $argv or $arg (why no dollar)
- in a multi-lang site with lang prefix, the lag will be in position zero? e.g. I tried

// Accept all pages, except
// ignore http://SITE/LANG/user/reset/xxxx
if
(arg(1) == 'user' && arg(2) == 'reset') {
return false;
} else {
return true;
}

#13

Status:active» closed (fixed)

#14

Nice one, #5 just saved my bacon.

I know this is colsed but does anyone care to comment about the concerns raised in #12? Is it possible for anything else to be used as the first arg and get around the PHP condition?

nobody click here