Admin & Dashboard PHP Intermediate

Hide Admin Notices From Non-Administrators

Stop plugin promotions and setup reminders appearing for editors, shop managers and clients, while administrators still see everything.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 7 lines
add_action( 'in_admin_header', function (): void {
	if ( current_user_can( 'manage_options' ) ) {
		return;
	}
	remove_all_actions( 'admin_notices' );
	remove_all_actions( 'all_admin_notices' );
}, 1000 );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

Plugins love admin notices: review requests, upgrade offers and setup nags. Clients and editors can’t act on most of them, and they bury real messages. This snippet hides the notice area for everyone except administrators.

How it works

WordPress prints notices on the admin_notices and all_admin_notices hooks, just after the admin header. The snippet runs on in_admin_header, shortly before that, and removes every callback attached to them for users who can’t manage options.

Things to watch

  • Useful notices are hidden too, such as “please update your password” or a plugin’s error message. Administrators should keep an eye on the dashboard.
  • Messages like “Post updated” in the editor and “Settings saved” use a different mechanism and still appear.

How to test it

Log in as an editor and visit the dashboard. Plugin banners that administrators see should be gone.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only