Search code examples
drupaldrupal-7drupal-rules

How to get Drupal Rules settings?


How to programmatically retrieve configuration of the specific rule?

I tried

$settings = rules_config_load('RULE_NAME');

It returns very basic info (name, ID etc) and empty "settings" array.

Cant also get it directly from DB .

It is stored in serialized array that can not be fully processed with the unserialize() function


Solution

  • I got the same issue and end up here, here is a solution i found, you need to call actions() on your rule to access settings:

    $rule = rules_config_load('RULE_NAME');
    foreach ($rule->actions() as $action) {
      $settings[] = $action->settings;
    }