I want to use Rules UI to define some action sets, but want to execute those actions programmatically from a custom module.
How to I execute the action by code and pass the needed arguments (just a node in this case).
Thanks!
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI want to use Rules UI to define some action sets, but want to execute those actions programmatically from a custom module.
How to I execute the action by code and pass the needed arguments (just a node in this case).
Thanks!
If you have set it up as a rules component, you can use rules_invoke_component
, alternative you can invoke an event, which could trigger mutiple rules by using rules_invoke_event
.
Both is similar in that you pass first a name/id and the rest of the args is passed along, so something like
rules_invoke_component('name', $node);
if your custom component rule has several parameters pass them one by one and separate them with comma as example
rules_invoke_component('rules_save_search_send_activation_sms', 'paramval1', 'paramval2', ....);
is properly how you need to do it. This again depends on how the rule/component is defined and configured.
rules_invoke_component('rules_mycomponent', $node);
– valderama
May 17 '11 at 15:03
rules_invoke_event
exists in 6 rules_invoke_component
does not, but I don't believe rules in 6 has the concept of components.
– googletorp♦
Jan 14 '12 at 9:25
rules_invoke_component('rules_save_search_send_activation_sms', 'test ', '93333333333');
– Yuseferi
Aug 6 '15 at 15:43