remove_action in plugin file

Im trying to use

remove_action( 'admin_notices', 'woothemes_updater_notice' );

In a plugin to keep from editing the themes functions.php file however the code isnt being executed. Do i need to wrap this in something to get it to work from the plugin files?

Related posts

2 comments

  1. Make sure you remove the action after the theme has added it. And use the same priority.

    A rather safe way is using the same action you want to clean up:

    add_action( 'admin_notices', 'remove_woothemes_updater_notice', 0 );
    
    function remove_woothemes_updater_notice()
    {
        remove_action( 'admin_notices', 'woothemes_updater_notice' );
    }
    
  2. Found the answer just after posting. If anyone is having the same issue i solved it with this.

    // Remove WooCommerce updater plugin notice
    function woothemes_updater_notice() {
        remove_action( 'admin_notices', 'woothemes_updater_notice' );}
    add_action( 'admin_head', 'woothemes_updater_notice' );
    

Comments are closed.