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.

7
  • 2
    possible duplicate of remove_action or remove_filter with external classes? Commented Mar 30, 2015 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? Commented Mar 30, 2015 at 19:20
  • what doesn't appear to work? there are several methods in those answers. Commented Mar 30, 2015 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. Commented Mar 30, 2015 at 20:53
  • How are you verifying the action status? In other words, how do you know your attempts are not working?
    – jdm2112
    Commented Mar 30, 2015 at 21:09

1 Answer 1

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 and acknowledge you have read our privacy policy.

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