Many plugins display notices and promotional messages that can confuse clients. This snippet hides admin notices for non-admin users.
Steps
- Open your WordPress theme
functions.phpfile. - Add the code below at the end of the file.
- Save the file.
- Log in as an Editor or other non-admin role to test.
Done — plugin and WordPress admin notices will be hidden from non-admin users.
⚠️ Important update notices will also be hidden from non-admin users.
function hide_admin_notices_for_non_admins() {
if (!current_user_can('administrator')) {
remove_all_actions('admin_notices');
remove_all_actions('all_admin_notices');
}
}
add_action('admin_init', 'hide_admin_notices_for_non_admins');