Support » Plugin: License Keys for WooCommerce » WordPress;how to remove_action from a Plugin to hide admin_notices created by an

  • Resolved webdevtestus


    I am a beginner to WP hooks, (actions and filters) I was able to create a Plugin that shows all 4 admin notices in the WP dashboard

    here the Plugin-one code

    /* Start admin notices on */

    function display_admin_notice() {
    <div class =”notice notice-success is-dismissible”><p>Congratulatios! it seems you have a nice success notice</p></div>
    <div class = “notice notice-error”><p>What a nice error message</p> </div>
    <div class = “notice notice-warning”><p>WARNING!!! site about to blow up in pieces</p></div>
    <div class = “notice notice-info is-dismissible”><p>INFO – you must renew license</p></div>

    add_action( ‘admin_notices’, ‘display_admin_notice’ );

    /* Stop admin notices on */`

    it works perfectly.

    Now I have another plugin that hides ALL notifications

    /* Start Block ALL admin notices */
    add_action('admin_enqueue_scripts', 'block_dismissable_admin_notices');
    add_action('login_enqueue_scripts', 'block_dismissable_admin_notices');
    function block_dismissable_admin_notices() {
       echo '<style>.wp-core-ui .notice{ display: none !important; }</style>';


    /* Stop Block ALL admin notices */`

    it works fine too

    BUT I need to REMOVE the action from the first Plugin, NOT to hide all notifications, I mean, is there a way to get the

    add_action( 'admin_notices', 'display_admin_notice'

    from the first Plugin and remove_action so the Plugin hides/block ONLY the admin_notices from THAT plugin and NOT from all the WordPress core or another plugin?

    I guess I should somehow hook to that
    add_action( ‘admin_notices’, ‘display_admin_notice’
    but I do not know how

    I have a plugin with this action
    add_action( ‘admin_notices’, ‘display_admin_notice’
    and need to call it from ANOTHER plugin to block those admin_notices

    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter webdevtestus


    ok, I found the solution
    here it goes

    add_action( 'init', 'remove_my_action' );
    function remove_my_action()
    global $wp_filter;
    remove_action( 'admin_notices', 'display_admin_notice');
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.