Paulund
2013-10-07 #wordpress

Hide WordPress Update Notice To All But Admins

When you have built your site on an open source project like WordPress one of the benefits you get is continuous updates and improvements to the core code. WordPress aims to release a couple of versions per year, when there is a new version of WordPress available to download there will be a notification bar at the top of your admin area. This notification bar will let you know that your WordPress version is out of date and that you need to update the core code.

WordPress Releases

It is highly recommended that whenever there is a stable release of WordPress to update as soon as possible, just so you are always running the latest code with the latest security updates. The problem with this is when updating on a live site, without knowing the affects of the update. With each release WordPress is trying to improve it's codebase, this could mean that it will improve on old functions of code or even remove old functions of code. If you have a plugin or theme that is using any of these old deprecated functions then it could break the functionality of your site or even bring down your entire site. For this reason you should always have a development site with the same plugins and themes where you can update WordPress to make sure that the new release will not break your site.

WordPress Update Notification

The WordPress update notification is shown to all users, but there is a different message depending on your access rights. WordPress admin users have a capability of update_core this allows them to run the update. Therefore only admin users can actually update the core WordPress code, but other users will get a message which says that a new version is available and to contact the site administrator. Depending on how your site is setup you might not want to show all users that you are running an out of date WordPress version and want to hide the fact that an update is available. Use the following code to hide the update message to all users except Admin users, simply add the following to your functions.php file.


function hide_update_notice_to_all_but_admin_users() 
{
    if (!current_user_can('update_core')) {
        remove_action( 'admin_notices', 'update_nag', 3 );
    }
}
add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 );