Closed (fixed)
Project:
Rules
Version:
7.x-2.9
Component:
Rules Core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
23 Jan 2013 at 11:59 UTC
Updated:
20 Jul 2018 at 03:04 UTC
Jump to comment: Most recent
Comments
Comment #1
redeight commentedI am also trying to figure this out myself. My current thought is that there might be a way to check the url to determine if it was updated via the user edit page... But I'm at a loss as to how this would be done. Does anyone know of a rule condition that checks that?
Comment #2
saurabh.dhariwal commentedPlease follow the below steps for your purpose:
Step 1 : Alter user edit with custom module.
Step 2 : Create custom rule event
Step 3 : Your rule conditions and actions set for this custom rule event.
Now, user update his profile your custom rule event will be fire and your action will execute with your rule.
Let me know if you face any query/concern regarding this.
Thanks!
Comment #3
redeight commentedsaurabh.dhariwal, unfortunately that won't work for either of our use cases. Mainly because that will fire anytime the user_save() method is called on a user object that already exists. We want this to only occur if the user_save() operation was the result of a user edit form submission. I haven't been able to find a way of checking what called the user_save().
Comment #4
redeight commentedI think I was able to figure this out. I implemented a form alter for the user edit form that adds a submit callback to the front of the submit callback list. I use the callback to check if the form was submitted via the "Save" button and set a 'flag' variable if it was (that way we know they are trying to update an existing user). I then implemented a variation of saurabh.dhariwal's "HOOK_user_update" that triggers our custom rules event if that variable was set.
Here's the code
And in YOUR_MODULE.rules.inc
Once you have that implemented, a new event will appear in the rules ui. Select that event and it works exactly the same as "After updating an existing user account" but it only fires when the user is manually saved via the form_user_profile form. Calls to user_save() from anywhere else will not fire the event.
Thank you saurabh.dhariwal for starting me on the right path toward a working rule event. =]
Comment #5
jelo commentedI linked these issues https://www.drupal.org/node/2780389 because my use case is exactly the same. I do a programmatic update on login which triggers my rule (which it should not). However, I cannot prevent it from happening right now, but hope to stop the condition to fail by introducing a new condition to check if an object exists. That would allow you to not trigger your rule if the account-unchanged object does not exist (which is the case when user_save fires without user edit previously)...
Comment #6
tr commented#4 provides a solution to the original question.
The post in #5 has its own open issue, so we don't need to keep this one open as well.