[Resolved] block non-admin users from seeing plugin update messages

Home Forums Support [Resolved] block non-admin users from seeing plugin update messages

Home Forums Support block non-admin users from seeing plugin update messages

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #896688
    Steig

    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

    #897027
    Tom
    Lead Developer
    Lead Developer

    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>';
        }
    } );
    #897091
    Steig

    I put that into my functions.php file and it didn’t remove the notification. I tested it under an author username.

    #897293
    Tom
    Lead Developer
    Lead Developer

    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?

    #897311
    Steig

    I’ve just emailed it to you.

    #898055
    Tom
    Lead Developer
    Lead Developer

    I just adjusted the function above – can you give it another shot?

    #898109
    Steig

    that did it. Thanks!

    #898253
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.