I've searched through WordPress Development and couldn't find the answer, so I either didn't search very well or I couldn't figure out the actual term I needed to search for...
I am trying to create a simple mu-plugin to remove update notices, nags and other random notifications created by many of the plugins I use across a lot of sites for clients. The plugin removes the notices for all except a single user.
The code below works, but I know I'm not removing the core, plugins and themes notifications.
That said, the issue I'm trying to tackle now (to no avail) is to be able to add multiple users who are able to see the notices (by username)... So, AdminUser
and AdminUser2
and AdminUser3
should see the notices when they're logged in.
I'm not much of a developer, so any help is much appreciated.
//Remove WordPress nags and notices from the WordPress dashboard for all but one user. REPLACE 'AdminUser' with your username
function hide_wp_dashboard_notices()
{
$user = wp_get_current_user();
if($user && isset($user->user_login) && 'AdminUser' !== $user->user_login) {
echo '<style>.update-nag, .updated, .error, .is-dismissible, .notice.woo-permalink-manager-banner, #try-gutenberg-panel, span.update-plugins, .yoast-issue-counter, table.wp-list-table.plugins .notice-warning { display: none !important; }</style>';
}
}
add_action('admin_enqueue_scripts', 'hide_wp_dashboard_notices');
add_action('login_enqueue_scripts', 'hide_wp_dashboard_notices');