Insert into rules.api.php, in hook_default_rules_configuration:

  $rule = rules_reaction_rule();
  $rule->label = 'example default rule';
  $rule->tags = array('Admin', 'Tag2');   // <- insert this
  $rule->active = FALSE;
  $rule->event('node_update')
//...

I figured it out, but it would have been even easier with an example to follow.

CommentFileSizeAuthor
#1 1917772-2.patch1.15 KBtr

Comments

tr’s picture

Category: Feature request » Task
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.15 KB

I just added that to the documentation. See Default rules

Of course, you know you could have done that yourself years ago, right?

I'm also adding it to the Rules test module, rules_test, found in the tests directory of your Rules distribution. The testing code serves as the definitive developer documentation because it is intended that the tests try out and verify all features of Rules, including in this case programmatic Rules configuration creation. When a feature is not being tested, like adding tags, then we should be adding a test to ensure that feature works and to provide an example of how to use that feature.

So in addition to the documentation fix, here's a patch for the rules_test module.

  • TR committed 32798e8 on 7.x-2.x
    Issue #1917772 by TR: Illustrate how to define tags in...
tr’s picture

Status: Needs review » Fixed

OK, that worked. Committed.

  • TR committed ca745d4 on 7.x-2.x
    Follow-up to issue #1917772 - update rules.api.php
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.