- Home
- Blog
- Contact
In WordPress we can remove update notifications from all users except specific roles, by username or by user ID. Below you can find a few examples that you can insert into your functions.php file.
By role
add_action('admin_head', function() {
if(!current_user_can('manage_options')){
remove_action( 'admin_notices', 'update_nag', 3 );
remove_action( 'admin_notices', 'maintenance_nag', 10 );
}
});
Code language: JavaScript (javascript)
By username
global $user_login;
get_currentuserinfo();
if ($user_login !== "joe") { // change joe to the username that gets the updates
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}
Code language: PHP (php)
By user ID
global $user_ID;
get_currentuserinfo();
if ($user_ID !== 1) { // change 1 to the id number that gets the updates
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}
Code language: PHP (php)