Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For registered users to my blog, if they click on the dashboard, they get an alert suggesting that they tell the site administrator (me) that the new version of WordPress is available.

All I want is to hide dashboard alerts from the subscribers. Where can I find the code to change this?

I found a site here that suggests that I'm looking for the code:

add_action('admin_head','addDashboardAlert');

But I don't know where to look for it.

UPDATE

I found some more relevant code to make the alerts conditional on user role, here:

if (!current_user_can('delete_posts')) {
share|improve this question

3 Answers 3

up vote 1 down vote accepted

you can include some custom css in your functions.php that hides the update_nag (notifications) element dependent on user capability:

add_action('admin_head','admin_css');
function admin_css()
{
if(!current_user_can('administrator'))//not and admin
{
    echo '<style>';
        echo '.update_nag{display:none}';
        echo '</style>';
    }
}
share|improve this answer
    
add_action and current_user_can won't work in functions.php; however, just hiding the elements with CSS seems to be the best way to do it so far. +1 –  bozdoz Oct 12 '12 at 3:24
    
add_action and current_user_can does work in your theme's functions.php - I have used this exact code in over 30 sites with not a drama? –  Clearmedia Oct 12 '12 at 3:39
    
Worked! Thanks @clearmedia –  bozdoz Oct 12 '12 at 15:11
    
Glad to help! Feel free to share my question - unresolved after many months, I've nearly lost all my hair over it! –  Clearmedia Oct 15 '12 at 1:56
2  
This is not really a good answer at all. –  Wyck Oct 15 '12 at 22:33

Updating this answer the original code below will remove the nag screen but it will ping the server for updates on every load, thanks to @ El Yobo, see update below.

This will disable the core updates and the nag screen to everyone but superadmins.

add_action( 'after_setup_theme', 'remove_core_updates' );
function remove_core_updates()
{
    if ( ! current_user_can( 'update_core' ) ) {
        return;
    }
    add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
    add_filter( 'pre_option_update_core', '__return_null' );
    add_filter( 'pre_site_transient_update_core', '__return_null' ); 
}  

To disable all plugin notifications;

remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', '__return_null' );

To remove a specific plugin you can try this but it is not 100% going to work depending on the plugin;

function ya_remove_plugin_update($value) {
     $plugin_relative_path = "plugin_relative_path"; // change this to your plugin
     unset( $value->response[ $plugin_relative_path ] );
     return $value;
}
add_filter( 'site_transient_update_plugins', 'ya_remove_plugin_update' );

Updated

This disable updates completely (I cannot get it to work based on user roles) AND stop pinging for updates (It will throw a PHP warning not sure how to fix this without altering core).

function remove_core_updates(){

        global $wp_version;
        return (object) array(
            'last_checked' => time(),
            'version_checked' => $wp_version,
            );
}
add_filter('pre_site_transient_update_core', 'remove_core_updates');
add_filter('pre_site_transient_update_plugins', 'remove_core_updates');
add_filter('pre_site_transient_update_themes', 'remove_core_updates');
share|improve this answer
    
Thanks @Wyck. Where would I put this info? Into wp-config? –  bozdoz Oct 11 '12 at 22:12
    
No these functions would go in your theme's functions.php or a plugin. –  Wyck Oct 11 '12 at 22:13
    
At the bottom? Top? Doesn't matter? @Wyck –  bozdoz Oct 11 '12 at 22:15
    
Not working in functions.php, says the functions are undefined: current_user_can –  bozdoz Oct 11 '12 at 22:24
    
That function will only work on WordPress 3.0 and above and must be called after functions.php loads, see here, wordpress.stackexchange.com/questions/14041/… –  Wyck Oct 11 '12 at 22:35

I didn't manage to work with those scripts above so I researched a bit more and found this:

//Remove update notifications from sub-users
add_action('admin_head','admin_css');
function admin_css()
{
if( current_user_can('YOUR_SELECTED_ROLE'))//Choose the correct role where you need to block update nag
{
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
}
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.