Hide Admin Notices From Non-Administrators
Removes plugin and theme notices, update nags and promotions from the admin for everyone who is not an administrator.
Opens WPIDE on
Code
add_action( 'in_admin_header', function () {
if ( current_user_can( 'manage_options' ) ) {
return;
}
remove_all_actions( 'admin_notices' );
remove_all_actions( 'all_admin_notices' );
}, 999 );
Notes
Messages like "Post updated" are not admin notices and keep showing.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.