I have created a redirect rule based on the "after updating an existing user account" event. However, this redirect is being applied every time a user logs into the site. I don't have any other rules enabled. Anyone know why this might be happening, and how to fix it?

Comments

paramnida’s picture

Issue summary: View changes
jigish.addweb’s picture

Checked this with same version of rule, and unable to reproduce issue. Please find attached screenshot for same and check whether you have missed any configuration for rule.

If you still face same issue then please send me screenshot where you are facing issue.

Thanks!

sath01’s picture

I can confirm this behaviour.

I ran a test with separate rule triggers on "before saving user account", "after updating an existing user account" and "user logged in" events which then logged to watchdog (and put up a message). The "after updating an existing user account" event does fire with each user login.

I had assumed it was something to do with the system updating the user's last login time, but that probably shouldn't fire the event anyway?

skulegirl’s picture

I'm also seeing this behaviour. It happens for the rule on my production site, but not for the exact same rule on my dev (localhost) site. There may be a few differences between the two sites, but I'm not sure what they are - they won't be big. I'll see if I can dig and figure out any significant difference that could cause this behaviour.

skulegirl’s picture

FYI - I've determined what the source of my issue is, and it's not related to this module. The ip2country module that I have installed was calling user_save to update the user's country after they logged in, thus the reason that the "after updating an existing user account" event was being triggered. (It doesn't happen on my localhost because it can't determine country from the ip.) You might try doing a grep in your modules directory to see if you have any modules that are calling user_save on login.

skulegirl’s picture

Also note: I ended up resolving this by just adding a condition to my rule:

Data to compare: [site:current-page:url], Data value: [account:edit-url]

Then it only fires if the reason the user is being update is because they actually were updating their account data on the account edit page.

tr’s picture

Category: Bug report » Support request
Status: Active » Closed (works as designed)

In this case, if you are using one of the many modules which alter the user account on login, Rules is doing the correct thing - there should be an "After updating an existing user account" event, because that is what is happening. I think #6 presents a good solution which, by adding additional conditions, more specifically and more accurately represents the situation that you want to test for.

bassplaya’s picture

@skulegirl Thanks. That worked for me too.