remove an action hook function on a plugin from a theme

The question:

first I did my homework by checking the answer on this question and this question, both didn’t work.
after long debuging the function I want to remove is protected in 2 nested classes, and follows this path:

class Sub_class{
    function __construct(){
        add_action('my_action_name',array(&$this, 'the_hated_function'), 200);
    }
    function the_hated_function(){
        // does some bs
    }
}
class Mother_class{
    public $my_propreity;
    function __construct(){
        add_action( 'init', array( &$this, 'init' ), 10 );
    }
    function init(){
        if(/* condition */ true){
            $this->my_propreity = new Sub_class();
        }
    }
}

so am trying to remove the hated function from a theme am creating.
for what it’s worth the plugin is availabe in the wordpress market place directory WCFM - WooCommerce Frontend Manager. the action hook is end_wcfm_products_manage and the hated function is wcfm_custom_field_products_manage_views.
am well aware the remove should happen after the function was added and before the hook is fired. and that the order number should also be considered (10 and 200) otherwise it wont work.
thank you all for your help.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Sounds like you could try the remove_action() function. Make sure to execute it after the action for “the hated function” is added.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment