I'm trying to remove or hide the update nags for non-admin users. As an admin, I see:
The popular answer I've seen to handle this says to use:
function hide_update_nag() {
if ( !current_user_can('update_core') ) {
remove_action( 'admin_notices', 'update_nag', 3 );
}
}
add_action( 'admin_head', 'hide_update_nag', 1 );
This works fine for removing the first message (WordPress 4.5.3 is available! Please update now) but leaves the second one visible to non-admins:
Both messages are wrapped in a <div class="update-nag">
, so one option is to modify the above chunk of code to use CSS to hide the nag with:
echo '<style>.update-nag {display: none}</style>';
But this feels kludgy to me. Is there a way to hook into an action or filter and remove ALL the update nag messages for non-admin users? No third-party plugin recommendations please.
admin_notices
only removes the first of the two messages and it seems that removing ( or hiding) the second message requires CSS.