How to disable all plugins/themes updates on all sub-sites?

As per plugin(s) activated on sub-sites, some plugins/themes will pop up notifications/notices and confusing clients. Any idea how to disable all and left super admin's notice only (which using Branda plugin)?

  • Mohammad Sharab
    • PM

    Hi iamJayChong,

    hope you are having a great day.

    We don’t have this feature in Branda plugin out of the box. But you can use the following code to hide all the notices for any user role on your network’s sites except the Super Admin role.

    Please create a disable-admin-notices.php file and add the code below. Upload the file to wp-content/mu-plugins/ folder. If mu-plugins folder doesn’t exist, just create it in thewp-content folder.

    <?php
    function hide_update_noticee_to_all_but_admin_users()
    {
    if (!is_super_admin()) {
    remove_all_actions( 'admin_notices' );
    }
    }
    add_action( 'admin_head', 'hide_update_noticee_to_all_but_admin_users', 1 );
    ?>

    Hope this helps. Let me know if this works for you and if you need any further assistance regarding this.

    Thanks,

    Mohammd Sharab

  • Mohammad Sharab
    • PM

    Hi iamJayChong ,
    I hope you are doing well today!

    The following code should disable all the updates notifications regarding plugins, themes & WordPress completely for non Super Admins users.

    Please replace the old code with this one in thte mu-plugin:

    <?php
    function remove_core_updates(){
    if (!is_super_admin()) {
    global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
    }
    }
    add_filter('pre_site_transient_update_core','remove_core_updates');
    add_filter('pre_site_transient_update_plugins','remove_core_updates');
    add_filter('pre_site_transient_update_themes','remove_core_updates');
    

    Hope this helps and please let us know if you need any further assistance regarding this.

    Kind Regards,
    Mohammad Sharab

    • Kyler
      • Web Slinger

      I tried creating the above mu-plugin but it’s not having the desired effect. Looking at the code, it makes me wonder if it’s only removing notifications about updates.

      Is there a way to remove dashboard notifications (like the ones in my screenshot) for subsites?

      [attachments are only viewable by logged-in members]

  • Pawel Pela
    • Ex Staff

    Hello Kyler !

    As you have noticed, there’s no consistent way of displaying notifications in WordPress yet. Some plugins add some PHP code to display those, others add the notice’s HTML from JavaScript added to the admin. This currently makes it nearly impossible to get all those notifications hidden, at least proactively. You can hide some, as per the code that was shared in this ticket earlier, but not all.

    What you can do is to use the built-in inspector in your browser, check for specific CSS classes and ids the notices have and hide them from Branda by using the Admin Area >> Custom CSS module, something like this:

    #some-plugins-notice-id {
    display: none !important;
    }

    As for something more permanent, there’s work being done by the core WordPress team which goal is to streamline the wp-admin notices and make them manageable. It’s being developed for this exact reason – there’s no easy way to hide all those pesky notifications. I’m one of the people who are also hoping this will help cleanup the mess caused by plugins adding ads for pro versions etc.

    Hope this helps a bit.

    Kind regards,
    Pawel

    • Kyler
      • Web Slinger

      Thanks Pawel! That Inspector/Branda workaround looks useful! I’m saving it for later.
      I’m happy to hear that the root problem is being worked on in WP.

      After I posted, I tried using the first code that Mohammd Sharab had posted (which iamJayChong later said no longer worked for them). Fortunately for me, in my case that code worked!

      So anyone reading this in the future, give both scripts a chance. YMMV.