Hi there,

I'm trying to remove some default rules, provided by another module, so I can override with my own rules.

I'm using hook_rules_default_configuration_alter

I can set $rules['example_rule']->active = FALSE; but if I unset($rules['example_rule']) it doesn't remove the rule.

Is it possible to remove default rules in hook_rules_default_configuration_alter?

Is there another way?

thanks,

DT

Comments

fago’s picture

Component: Rules Core » Rules Engine
Category: bug » support
Status: Active » Fixed

Unsetting will only work if you take the parameter by reference.

davidwhthomas’s picture

Status: Fixed » Active

@fago thanks very much for the reply.

I'm passing the parameter by reference ( see below ) but it still doesn't appear to remove the default rules, despite clearing all caches with drush cc all

/**
 * hook_default_rules_configuration_alter
 */
function example_default_rules_configuration_alter(&$rules) {

  // These rules are all overridden below with custom versions
  // We need to deactivate the commerce default rules
  if( isset($rules['commerce_checkout_new_account']) ){
    unset($rules['commerce_checkout_new_account']);
  }
  if (isset($rules['commerce_checkout_order_status_update'])){
    unset($rules['commerce_checkout_order_status_update']);
  }
  if (isset($rules['commerce_checkout_order_email'])){
    unset($rules['commerce_checkout_order_email']);
  }
  
}

Is there something else needed there?

DT.

P.S Rules rules :)

mrfelton’s picture

Component: Rules Engine » Rules Core

I'm getting the same issue. Was working for me, until I just updated to the latest dev code.

TR’s picture

Issue summary: View changes
Status: Active » Closed (cannot reproduce)

I am doing an unset() exactly like in #2, and everything works for me. I don't know what the problem was 6 years ago, but this feature seems to work fine now in the current version of Rules.

If this is still a problem for you, post your code and describe the steps you're taking to test this, and I'll try to figure out what's wrong.