1

I have a Rule that does a few things when the user is first created ("After saving a new user account"), it interacts with a remote web service which provides a value, and then I save that value in a field of the user's account.

That "save" when the user is registered triggers the "After updating an existing user account" because it's also saving an entity property.

I have also rules that should trigger when the users are updated, but not when the previous rule created it!

I tried using a hidden value, but this doesn't help as I need to reset that value at some point and when I do, another "After updating an existing user account' is triggered!

Basically I need a way to tell a rule save an entity's property, user in this case, without triggering the "After updating an existing entity" or if triggered, avoid execution.

I am planning on working around this with a custom semaphore rules action that sets a static variable, but I really would like to know if there's a way of doing this properly without custom code.

  • 1
    it's not much better but you could use a hidden field that the first rule sets, and the second checks - if it has no value, the second rule continues (human created), if it has a value the second rule doesn't run since it is machine made – Geoff Feb 19 '15 at 20:11
  • Thanks, but I kind of mentioned using a hidden value in the question. Basically I end up with the same issue. Rule 1 on create executes and set the hidden value. Rule 2 on update check for hidden value and do not execute. So far so good, but then I need to reset that hidden value in order that Rule 2 does execute when the user is updated. Now I need a separate rule to reset the hidden value because I can't use Rule 2 to do that because it wasn't run. So Rule 3 reset hidden value after Rule 2 and Rule 3 now triggers Rule 3 again! Maybe with some components or "Conditional rules" can be made. – Mescalito Feb 20 '15 at 13:54
  • apparently I read it too quickly - well, then I would surmise that you don't have it set up properly. I have done it very successfully in the past this way, nothing needs to be reset. – Geoff Feb 20 '15 at 16:31
  • But how would you do it? My logic in my mind is: If user is created, do something, set hidden field 'do not update'. (setting the hidden field will trigger 'update'). If user is updated and hidden field is not 'do not update', do something. So for so good, but if the user is updated afterwards (not from the creation rules) I still want that rule to fire. If I don't set reset the hidden field that rule would never fires. If I add another rule to reset the hidden field afterwards, it will trigger the original one. I still think that using components is the way to go, or conditional rules mod. – Mescalito Feb 20 '15 at 20:29
  • Please refer to this answer - it may help to solve your question drupal.stackexchange.com/a/218846/7274 – fkaufusi Oct 26 '16 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.