To remove plugin notices for non-admin users

The simplest way would be to hide the notifications via CSS, see below:

    function hide_update_msg_non_admins(){
     if (!current_user_can( 'manage_options' )) { // non-admin users
            echo '<style>#setting-error-tgmpa>.updated settings-error notice is-dismissible, .update-nag, .updated { display: none; }</style>';
        }
    }
    add_action( 'admin_head', 'hide_update_msg_non_admins');

A more detailed answer can be found here.

Leave a Comment