Archived topic
block non-admin users from seeing plugin update messages
7 replies · Started by Steig on May 11, 2019
Hello
I have a plugin that keeps showing a notice about updating to the pro version that shows at the top of basically every WP menu on the left column (i.e. dashboard, posts, media, pages, etc). I don't mind they show this to the admin login, although I'm already aware that I'm not using the pro version. But this same notification is showing for other logins on the system. i.e. the author and editor roles that I care about particularly. People in that role can't do anything about the plugin anyhow and it doesn't look professional to show it to them. Can I block those messages from showing up? I'd prefer to block for everybody, but at a minimum the author and editor roles.
Thanks
Hi there,
You could try a function like this:
add_action('admin_head', function() {
if ( ! current_user_can( 'administrator' ) ) {
echo '<style>';
echo '.notice, .sgpb-license-notice{display:none}';
echo '</style>';
}
} );
I put that into my functions.php file and it didn't remove the notification. I tested it under an author username.
Hmm, it's possible the notice isn't using the standard .notice class I suppose. Can you right click the notice and click "Inspect", then show me a screenshot of the code?
I've just emailed it to you.
I just adjusted the function above - can you give it another shot?
that did it. Thanks!
You're welcome :)