I'm a newbie and using the Rules module, but Rules Event "user has logged in" won't trigger my rule.

I can set any event to trigger a rule (for example, user has logged out), but if I change it to "User has logged in", the rule is never triggered, even if conditions and actions remains the same.

This doesn't work:

  • Event: User has logged in

  • Conditions: None

  • Actions:

    • Set a data value
    • Parameter: Data: [account:field-point], Value: 1

But if event is: "user has logged out", there is no problem, the value changes to 1.

I had used "user has logged in" as an event in another site and it works, but in this particular case it won't.

Any idea why?


I found the problem... maybe.

At a user's first log in I have a (first) rule to remove one role "new" and add a new one "active", I also set the date of first log in in a field and a second date that has a 1 year offset. The condition to this rule is if the user account has the role "new".

A user can also set some fields of his profile to be private or public by changing a field text list, I did this by setting a (second) rule that after updating a user account changes a set of cloned fields to blank when the value of a field is "private" and a (third) rule that copies the data from the original fields to the cloned ones when user selects "public". Both rules are triggered after updating a user account.

In this case, the first rule to change user roles never triggers; if I disable the third rule triggered after the user account is updated, then the first rule runs as expected.

So, it looks like I can't have two rules triggered by the same action, in this case, two rules triggered after the user account is updated.

The problem is solved by setting the third rule to trigger before saving a user account, but I still don't know what caused the problem.

  • Have you checked this particular action is not perform in this condition or any other action also not performing ?
    – Rupesh
    Commented Apr 3, 2014 at 3:27
  • Can you replicate the issue on a clean install? What's your setup? Try showing a message "You successfully logged in" to make sure the rule is triggered for real;. Commented Apr 3, 2014 at 7:50
  • I doubt a clean install is going to produce different results. Instead an approach as in my answer will probably be much more effective ... Commented Feb 20, 2016 at 11:19

1 Answer 1


Challenging Rules question ... also because there seem to be some things in it that don't match with Rules terminology or functionality. Read on for more details ...

Part 1: Refinements of your question

Rules: Event user has logged in won't trigger rule

This is a pretty confusing title: Rules Event "User has logged in" should always be triggered ... when a user logged in. If that's not happening, then that seems ike a Rules-bug. Therefor I think a better title is "Why is my Rules Action not executed when using Rules Event 'User has logged in'?". If you agree, please edit your title like so.

I can set any event to trigger a rule ... the rule is never triggered.

Rules Events are triggered by Rules, "you" cannot "set" them. Using custom code you may enhance Rules to trigger "custom" events to be triggered by Rules. Since this question is not about custom code, I assume you wanted to say "No matter which Rules Event I try to use ... the rule is never triggered".

... two rules triggered by the same action

Rules are NOT triggered by an action, they are trigger by a Rules Event.

Advice: Rules is all about Events, Conditions and Actions (ECA for short). You really need to think with those 3 crucial terms when using Rules ... And rephrase your question accordingly.

Part 2: Attempt to answer your question

What might explain what's happening

Have a look at issue # 430274, about an event which is a variation of your event here, and somehow explains that "after saving something" actually happens "before saving something". This is not a bug, but simply how the Rules module works.

A possible compromise to avoid these kind of issues, is to transform what's you're trying to do into a Rules component, so that your original Rule "schedules the execution" (using the Rules Scheduler sub-module) of that Rules component. For example after only a few seconds or minutes if your cron job runs frequent enough (otherwise it'll be next time cron runs). This compromise will ensure that, at the time the Rules component is executed, the entity is for sure saved (so that can't be the reason anymore then why things don't work as expected).

Rules debugging

You clearly have a combination of rules that need some debugging. Rules is great, but sometimes also tough to debug if things don't work as you'd expect. There are some typical facilities to do such debugging, but my Keep-It-Super-Simple technique I often use is my BINGO-trick. A sample of such rule can be found in my answer to "Which Rules condition can be used to email a user when an admin updates their profile?". Obviously, if you have more then 1 rule (like 3?), you may want to make it like Bingo1, Bingo2, Bingo3. Depending on the order they are shown, you also know the order of execution. Stupid, but simple and efficient (I think).

For more suggestions about Rules debugging, refer to "How can I display the value of a variable inside a condition?"

Use Conditional Rules

In your case there are 2 rules involved that are triggered by the same Rules Event (= after user acount is updated). But how do you know in which "order" (which Rule gets executed first)? There might be some logic in rules somewhere to find the answer to that question.

But instead of searching for that answer (or hope the order matches with what you'd hope), I simply use the Conditional Rules module in such cases. Not only does it allow me to merge multiple rules together in a single rule (= much easier to maintain, etc), but "I" am in full control about the actual Rules Conditions (within a Rules Action!), and I can set the order of them in the way "I" want/expect them to be. You can use Conditional (if/else) logic within the Rules Action, or you can also use Switch logic.

For an example using the Conditional Rules module (for which there is not a lot of docu available), refer to my answer to the question "How to prevent a node being saved when using the Rules module?".

Be aware: this module only has a beta release for D7, though it's used in over 8K sites (which makes it seem like a pretty robust module though).

Video tutorials

If you're not familiar with Rules, checkout the video tutorials Learn the Rules framework.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.