1

I'm looking for a way to alter the variables before a rule is executed. Specifically, I'm trying to add a list of users who should be notified of a new comment so that I can create a loop and send an email to each.

I have implemented hook_rules_event_info_alter as follows:

function mymodule_rules_event_info_alter(&$events)
{
    $events['comment_insert']['variables']['affected_users'] = array('type' => 'list<user>', 'label' => 'Anyone that should be notified about a new comment.');
}

However, I am at a loss as to which hook needs to be implemented in order to fill in this variable before it is used. (On my site the default will be the node author, however there are some nodes where several users should be notified).

2 Answers 2

0

The implementation should be placed into the file MODULENAME.rules.inc, which gets automatically included when the hook is invoked.

1
  • Thanks @monymirza, but what sort of implementation are we talking about? Can you provide a link to an example? Thanks.
    – Godwin
    Mar 27, 2013 at 4:52
0

In the end I discovered I don't actually need to create my own variable to do this, instead I can add the list of members via the views conditions. Select 'Entity has field' and choose you list field. Now when you add a loop, the field will come up in the data selectors.

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.