I have a collection of email notifications created with Drupal Rules module and a separate custom database table with the ID's of the rules and emails to exclude from individual notifications.

I need to know which rule is being triggered so I can query my custom table for the correct emails to exclude. Creating custom conditions would not work because I have 20+ rules using the same custom action.

The only hook that I can find that is triggered after a rule is executed is hook_rules_config_execute but it does not give me information only on the specific rule that triggered.


1 Answer 1


Below are 2 approaches that might work ...

Approach 1

Create a NEW Rules Component like so:

  • It uses some "identifier" as a parameter, of type something like "text" or "integer".
  • All this component does, is to also perform your custom action.

For each of your existing rules, rework that Rules Action like so:

  • Replace it by performing the new Rules Component.
  • For the (required) parameter of the Rules Component, use some unique value (just an integer, or maybe the machine name of the rule?), so that when the Rules Component is executing, you do know which rule it was that triggered the execution of the Rules Component.

Approach 2

Update each of your rules to contain and pass in a unique identifier. You can just do that by adding another parameter to the existing Rules Action in your rules_action_info hook. Though you'd have to update all your existing rules to make that work.

  • Sounds like you're suggesting I update each of my rules to contain and pass in a unique identifier. I can probably just do that by adding another parameter to the existing action in my rules_action_info hook. I was hoping to find a solution to avoid having to update all my existing rules but that could work.
    – techie
    Commented Jan 10, 2018 at 17:17
  • @techie yes indeed, each of your rules would have to be updated. And I cannot think of any other way without such update. Moreover, "just adding another parm to the existing action" is indeed another variation (= further improvement of my suggestion in this answer?). I thought about that too when posting my answer, but wasn't sure if that would be acceptable to you also. Should I slightly improve my answer to add that as a possible alternative? Commented Jan 10, 2018 at 17:22

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.