0

I am using Commerce Kickstart 2 with the their blog module, which includes a hook_preprocess_node() I need to short-circuit.

I looked at How to "unhook" a hook from a module? and I thought I could put the following in a module.

function my_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'commerce_kickstart_blog_preprocess_node' && isset($implementations['commerce_kickstart_blog_preprocess_node'])) {
   unset($implementations['commerce_kickstart_blog_preprocess_node']);
  }
}

It doesn't do anything. What am I doing wrong?

1 Answer 1

1

$implementations is an array whose keys are the short name of the enabled modules; $hook is the name of the hook, without hook_ nor the short name of the module.

You need to change your code to the following one.

function my_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'preprocess_node' && isset($implementations['commerce_kickstart_blog'])) {
   unset($implementations['commerce_kickstart_blog']);
  }
}

I assume the short name of your module is my; if it were my_module, then you would need to use the following code, since the hook is hook_module_implements_alter().

function my_module_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'preprocess_node' && isset($implementations['commerce_kickstart_blog'])) {
   unset($implementations['commerce_kickstart_blog']);
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.