Stop plugin promotions and setup reminders appearing for editors, shop managers and clients, while administrators still see everything.
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 );
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.
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.
Log in as an editor and visit the dashboard. Plugin banners that administrators see should be gone.