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!
Snippet (PHP): Hide Plugin/Theme Update Notifications For All Users But 1 @ WordPress Admin Dashboard
/** * @snippet Disable Update Notifications @ WordPress Dashboard * @how-to Get CustomizeWoo.com FREE * @sourcecode https://businessbloomer.com/?p=103268 * @author Rodolfo Melogli * @compatible WooCommerce 3.5.3 * @community https://businessbloomer.com/club/ */ add_action( 'admin_init', 'bbloomer_hide_update_notifications_users' ); function bbloomer_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', 'bbloomer_disable_update_notifications' ); add_filter( 'pre_site_transient_update_plugins', 'bbloomer_disable_update_notifications' ); add_filter( 'pre_site_transient_update_themes', 'bbloomer_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 bbloomer_disable_update_notifications() { global $wp_version; return (object) array( 'last_checked' => time(), 'version_checked' => $wp_version, ); }
Hi Rodolfo,
It might be useful to leave a way to see the updates, when a certain url parameter is set.
For example, calling /wp-admin/update-core.php?showupdates
Cheers!
Nice, grazie!
Hi Rodolfo! You seem to have an answer for everything, I love that!
This works so well for me except a couple of little things โ on page /wp-admin/update-core.php I have a bunch of notices like this:
Plus the Re-install Now and Hide this update buttons are still showing. Other than that it looks good โ says WP, plugins, themes and translations are all up to date (a white lie but I know this is standard =).
And also (possibly more important because it shows throughout admin), the red circle next to the plugins item in the menu sidebar is still showing (but when I click into that menu, all of the update warnings are gone which is awesome =)
Would be so great if you could help with these, thanks for all you do!
I’m using WPv5.1.1 + WCv3.6.3
Cheers!
Hello Billy, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
seriously? what are you doing? it’s messed up again.
Ah thanks Jennifer, you’re right, HTML got decoded for some reason. Snippet fixed ๐
He’s referring to this:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘bbloomer_disable_update_notifications’ not found or invalid function name
Gotcha! Fixed & thank you ๐
you have a wrong callback.
Thank you Tommy! Could you be more specific please so I can revise the snippet? Cheers
Ah thanks Tommy, I figured it out thanks to James as well. Snippet has now been revised. Cheers ๐