0

I've searched around but haven't been able to find a solution to this. I'm trying to hook in and remove an action that was initiated by a plugin (specifically the Groups plugin). The function itself is contained within a class in the plugin. It basically breaks down like this

class Groups_Registered {
...
    public static function init() {
       add_action( 'user_register', array( __CLASS__, 'user_register' ) );
    }
...
}
Groups_Registered::init();

I've tried to just remove the action, referring back to the class, but it doesn't seem to be working. I've added this to my functions.php file, but it is not removing the action. A

remove_action( 'user_register', array( Groups_Registered::init(), 'user_register' ) );

Anyone know how to solve? I've seen some solutions out there but none of them seem to work.

  • 2
    possible duplicate of remove_action or remove_filter with external classes? – Mark Kaplun Mar 30 '15 at 19:05
  • @MarkKaplun that doesn't appear to work. I think because the Groups_Registered class is not actually initiated or set in a variable? – Jason Hoffmann Mar 30 '15 at 19:20
  • what doesn't appear to work? there are several methods in those answers. – Mark Kaplun Mar 30 '15 at 19:33
  • @MarkKaplun well, any of them. I tried: function mfields_test_remove_actions() { remove_action( 'wp_footer', 'my_wp_footer' ); remove_action( 'wp_footer', array( 'MyClass', 'my_action' ), 10 ); remove_action( 'wp_footer', array( 'MyStaticClass', 'my_action' ), 10 ); } add_action( 'wp_head', 'mfields_test_remove_actions' ); with user_register and the Groups_Registered class, but that didn't do it. – Jason Hoffmann Mar 30 '15 at 20:53
  • How are you verifying the action status? In other words, how do you know your attempts are not working? – jdm2112 Mar 30 '15 at 21:09
3

Just match the callback in your remove call - array( CLASSNAME, METHOD ):

remove_action( 'user_register', array( 'Groups_Registered', 'user_register' ) );

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.