Disabling the update nag of wordpress

November 30, 2008 · Print This Article

WordPress’ core update nag is quite the useful thing, I’ll usually know before it shows that there’s an update, but a lot of people won’t. If you don’t know what I mean with core update nag, it’s this thing:

WordPress x.x.x is available! Please update now.

 The issue is that this thing doesn’t only show to you, it shows to all users of your blog.

A better thing to do is add this code to your themes functions.php:


if ( !current_user_can( 'edit_users' ) ) {
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}

This will show the nag to you, but prevent “normal” users from seeing it.

What about making it show to a certain user id/name? Here’s how to show them to a certain username, in this case “admin”:


global $user_login , $user_email;
get_currentuserinfo();
if ($user_login == "admin") {
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}


Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.