Home » WooCommerce: Disable Update Notifications @ WordPress Dashboard

WooCommerce: Disable Update Notifications @ WordPress Dashboard

by Tutor Aspire

We talked a lot about safely updating WooCommerce. The same applies to WordPress core, other plugins, themes… WordPress is such a delicate piece of software that you should ALWAYS know what to do before actually doing it 🙂

Sometimes, website managers feel great about clicking on that “Update Now” link in their WordPress dashboard. It seems – and it is – so easy. Problem is, they’ll likely break the website.

The best way of doing this properly is to run the updates (as well as custom code, plugin tests, design changes) on a “staging environment“, which should be provided by your hosting company.

Either way, those “Update Now” links are too dangerous. Only you (the developer) need to know that – while it’d be better if the other users who have access to the dashboard didn’t see anything and concentrated on WooCommerce orders or WordPress post and content editing.

Clearly, there is a way to disable the update notifications on a per-user basis or, even easier, to only have 1 user (possibly you) see these. The snippet is a little complex, but there is a lot of literature online – this is the one that worked for me!

Hide and disable plugin/theme update notifications for certain users @ WordPress Dashboard

Snippet (PHP): Hide Plugin/Theme Update Notifications For All Users But 1 @ WordPress Admin Dashboard

/**
 * @snippet       Disable Update Notifications @ WordPress Dashboard
 * @how-to        Get tutoraspire.com FREE
 * @sourcecode    https://tutoraspire.com/?p=103268
 * @author        Tutor Aspire
 * @compatible    WooCommerce 3.5.3
 * @donate $9     https://www.tutoraspire.com
 */ 

add_action( 'admin_init', 'tutoraspire_hide_update_notifications_users' );

function tutoraspire_hide_update_notifications_users() {
    global $menu, $submenu;
    $user = wp_get_current_user();

    // ENTER HERE THE ONLY ALLOWED USERNAME
    $allowed = array( 'rodolfomelogli' );

    // HIDE WP, PLUGIN, THEME NOTIFICATIONS FOR ALL OTHER USERS
    if ( $user && isset( $user->user_login ) && ! in_array( $user->user_login, $allowed ) ) {
        add_filter( 'pre_site_transient_update_core', 'tutoraspire_disable_update_notifications' );
        add_filter( 'pre_site_transient_update_plugins', 'tutoraspire_disable_update_notifications' ); 
        add_filter( 'pre_site_transient_update_themes', 'tutoraspire_disable_update_notifications' );
    
        // ALSO REMOVE THE RED UPDATE COUNTERS @ SIDEBAR MENU ITEMS
        $menu[65][0] = 'Plugins up to date';   
        $submenu['index.php'][10][0] = 'Updates disabled';   
    }
}

function tutoraspire_disable_update_notifications() {
    global $wp_version;
    return (object) array( 'last_checked' => time(), 'version_checked' => $wp_version, );
}

You may also like