Fire Rule Set programmically

Events happening in the community are now at Drupal community events on www.drupal.org.
class01's picture

Hello,

How can I fire a rule using PHP?

Thanks,

Jonathan

Comments

The best way is: take him to

szadok's picture

The best way is:
take him to your office, tell him he is fired and give him a 30 days notice in writing.... ;-D

(sorry, I had too.... )

Not just any writing!

itangalo's picture

You'll probably have to use something like

<?php
print "Rule set, you are fired.";
?>
if you want to fire the rule set with PHP. To give a 30 days' notice I would suggest using Rules Scheduler.

Heh.

Another way of doing it is using rules_evaluate_rule_set() or possibly rules_invoke_rule_set(). I don't really know how to use them (and I have never tried calling a rule set in code), but you can proabaly/hopefully find what you need on the following pages:

http://drupalcontrib.org/api/function/rules_evaluate_rule_set/6
http://drupalcontrib.org/api/function/rules_invoke_rule_set/6

(I was a little confused by the second argument in rules_evalute_rule_set. And the third and the fourth one.)
If you find an easy way to describe how to call rule sets from PHP, a line or two in this thread would be appreciated.

Good luck!
//Johan Falk, NodeOne, Sweden

Got it!

itangalo's picture

I knew I'd seen this question before:
http://groups.drupal.org/node/61018#comment-190358

Good luck,
//Johan Falk

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: