I'm using the Rules module and I have two rules:

  • A: When flagged, 'Post a journal entry to the ledger'
  • B: When unflagged, 'Remove journal entry from the ledger'

Rule A includes also two Rules components with conditions that check if the journal entry is balanced:

If the condition 'balanced' is true: - Post journal entry to the ledger.

If the condition 'unbalanced' is true: - Show a warning on the page and UNFLAG the journal entry.

The problem is that I don't want the Rule B to be triggered inside rule A, which currently happens.

Theoretically I could add a condition to Rule B like 'is balanced' but I don't want to modify other rules in order to prevent the execution of a rule inside a rule.

Is it possible to prevent nested Rules from firing?

  • Welcome to Drupal Answers! You cannot change the question once you get an answer, if that invalidates the given answers. Just accept the answer not requiring that other module, if you feel like not using it.
    – apaderno
    Commented Jul 12, 2016 at 20:09

3 Answers 3


This is a workaround solution.

You could add a boolean field to your journal entry content type. Side note, you could use the Field Permission module to hide the boolean field from the add/edit form.

Alternatively, if you're not using the sticky system, you could use that instead.

So now all you gotta do is add a condition to your Unflag Rule.

  • Boolean is false/unchecked OR content is unsticky.

Now in your Component Action add:

  • Set a data value and make your boolean True/checked OR Make content sticky
  • Unflag node
  • Set a data value and make your boolean false/unchecked OR Make content unsticky

enter image description here

Voilà!!! your component will not trigger your unflag rule.

  • Seems like an interesting approach / alternative. Though I'm not sure I understand for 100% how it answers the question. But that's mostly because it still is not clear to me how exactly the 2 rules and the 2 rules components (as in the question) should work together (reft to my comment below the question. Maybe you can think of a way to enhance your answer that might help to better understand the question? Commented May 26, 2016 at 11:31

You may get closer (= simplify your Rules logic) by ALSO using the Conditional Rules module. Some more details about this module (from its project page):

... provides Rules plugins for conditionally altering execution flow directly inside a group of actions.

Here is a screenprint of a rule with an action that uses Conditional Rules (though only with an "if"-part here, no "else"):

enter image description here

For a sample 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).

  • Thanks good example. However I have just lost a day using Conditional Rules module because it is not stable enough. Saving data does not work inside a Conditional section, see also that issue queue. I rather use an alternative approach.
    – Yuri
    Commented May 7, 2016 at 19:09
  • sorry to hear that, but I suggest you enhance your question with something like "without using Conditional Rules". Also, which "issue" are you referring to? Commented May 7, 2016 at 19:11
  • Done, thanks. And the Conditional Rules issue I referred to is drupal.org/node/2173285
    – Yuri
    Commented May 7, 2016 at 19:25
  • @Pierre.Vriens like my answer?
    – No Sssweat
    Commented May 25, 2016 at 22:10
  • @NoSssweat yes ... Commented Apr 3, 2017 at 12:04

Sometime you need to prevent the next rules from executing.

  • In your rule, you can add an action "Execute custom PHP code"

You can put this code to redirect to a different page rightaway without execute the next rule.


The above code will do a page redirect to the home page and that's it.

The rest of the rules will never get execute.

  • FYI: for anyone goes down this path, you'll want to consider the entire page request context. Abruptly terminating the PHP execution might have unexpected consequence (e.g. hook_exit() not firing).
    – Shawn Conn
    Commented Oct 26, 2016 at 3:17

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.