I am trying to remove an action from Woothemes' Sensei plugin.

If I do on the functions.php:

global $woothemes_sensei;
remove_action('sensei_lesson_video', array($woothemes_sensei->frontend, 'sensei_lesson_video'));

I can remove the action.

But if I do the same on a plugin, I can't.

Actually, the problem is that after var_dumping $woothemes_sensei on a plugin a get NULL.

Why is that?

EDIT: Well, here is the answer. I should put the code inside a function and hooked it to initor after_setup_theme. But I found a Sensei hook, that runs before the loop (sensei_before_main_content). So I did:

    add_action('sensei_before_main_content', 'trib_s2sensei');

function trib_s2sensei() {

   global $woothemes_sensei;
   remove_action('sensei_lesson_video', array($woothemes_sensei->frontend, 'sensei_lesson_video')); 
  • when does the plugin add that action? what action do you run your code on?
    – Milo
    Feb 7 '15 at 20:53
  • I could not understand your questions. I am saying that this exactly code works on the functions.php theme file but not on a custom plugin. Is it a matter of when? Should I run this code on any wp action hook when placing it on a plugin?
    – Luis Rock
    Feb 7 '15 at 21:43

The include of custom code via theme is different from the including via plugin. It is important, that you add a hook to include your custom source inside the plugin, like after_setup_theme, maybe with a low priority, after the default theme init his code.

  • Well, it worked hooking it to after_setup_theme. Thanks for the suggestion. But don't you think it would be better hooking it to init ?
    – Luis Rock
    Feb 7 '15 at 22:18
  • The hook is depending from the hook, there was used from the source, there you will remove.
    – bueltge
    Feb 7 '15 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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