0

I'm using the Rules module in Drupal 7, and I tried to add a new Rules "Action"

I followed the steps described in How to create an custom rule action using hook_rules_action_info? to create a custom rule action using hook_rules_action_info:

  • I tried to create a sample file (save_nid.rules.inc) in the folder /rules/module/.
  • And I also tried to create a module folder in /site/all/module/save_nid/.

My code in save_nid.rules.inc looks like so:

  function rules_save_nid_action_info() {
      return array(
      'save_nid_action' => array(
        'label' => t('Custom Action'),
        'parameter' => array(
          'param1' => array(
            'type' => 'int',
            'label' => t('Parameter Label'),
          ),
          'param2' => array(
            'type' => 'commerce_order',
            'label' => t('Parameter Label2'),
          ),
        ),
        'configurable' => FALSE,
        'group' => t('ABC Custom module action'),
        'callbacks' => array(
          'execute' => 'abc_custom_action',
        ),
      ),
  }

After I cleared the Drupal cache, I didn't see my "custom rule" in the list.

What am I missing or doing wrong?

Pierre.Vriens
  • 2,117
  • 75
  • 29
  • 42
JuseNNN
  • 13
  • 7

1 Answers1

1

In your case, the machine name of your custom module seems to be save_nid.

So if you want to use hook_rules_action_info in your module, your function needs to be named save_nid_rules_action_info, instead of rules_save_nid_action_info.

Not sure if it is the "only" problem why you can't get it to work, but at least it is "a" problem you need to address.

PS: make sure to save that custom coding in your custom module's folder (in /site/all/module/save_nid/).

Pierre.Vriens
  • 2,117
  • 75
  • 29
  • 42