1

I have several conditions that are called in rules_condition_info () and wanted to have an action for each, for whenever a function returns true, it is called an action. I know it's probably possible, but how do I tell the action you want to perform a certain action for a certain condition ... thanks

0

Events, conditions and actions are bound together in a Rule. So to match them up you need to define them in your Rule. I am assuming you want to create a Rule programmatically to go along with your hooks?

You can define events, conditions and actions, as you say with hook_rules_event_info(), hook_rules_condition_info() and hook_rules_action_info(), but to create a default Rule, you'll need to use hook_default_rules_configuration(). It is recommended you put the hook implementation in MODULE.rules_defaults.inc to optimize the memory footprint.

For further details on how to use the hook, see Default rules in the Site Building Guide, and look at the default Rules the module provides.

Personally I would recommend that you build your Rule through the UI and featurise, or export it as a Rules string and then import it like so:

function MYMODULE_default_rules_configuration() {
  $items['test_rule'] = entity_import('rules_config', 'EXPORT STRING HERE');
  return $items;
}

That will save you a lot of pain.

  • Thanks, I created rules programmatically with hooks. I will try to solve, but thank you for the suggestion. – user1993942 Jun 4 '14 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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