Hide WordPress Update Notices for Non-Admin Users

The following code ensures that no user logged into the WordPress dashboard will see WordPress version update notices:


    global $user_login;
    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;" ) );
    }

Change “admin” to the username that should receive updates.

Alternative version that shows the update notice to all site administrators, not just the user named “admin”:


    global $user_login;
    get_currentuserinfo();
    
    if (!current_user_can('update_plugins')) {
          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 uses WordPress hooks. Learn more in WordPress Hooks Explained.

Discussion
[  0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!