3

How to hide/disable any plugin notices for non admin users in dashboard? Can you please help me with this? Thanks

2

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.

  • Hi Adrian! Thanks for your response. However,I have tried using your snippets. It didn't work for me. Non admin user (Editor for my case) can still see some plugin notices.(It says the user don't have permission to install that plugin). I want to hide this types of message for any user other than admin. Any suggestion? Thanks again. – Nizam Uddin Sikder Nov 10 '15 at 16:12
  • I have slightly modified your snippet and it worked perfectly for me. Thanks. function hide_update_msg_non_admins(){ if (!current_user_can( 'manage_options' )) { 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'); – Nizam Uddin Sikder Nov 10 '15 at 16:58
  • Great, I've updated the code! Please mark my answer as approved. – Adrian Spiac Nov 10 '15 at 17:38
1

You can try following piece of code in your functions.php

if ( current_user_can( 'manage_options' ) ) {
} else {
echo ".update-nag , .error, .updated{ display:none; }";
}
  • It will hide notices & warnings for all non-admin users – Zaheer Ahmad Khan Jan 14 '16 at 22:01
0

This works for me:

add_action('admin_head', 'admin_only_warnings');

function admin_only_warnings() {
if(is_admin() && !current_user_can('administrator') ) {
  echo '<style>
    <!-- add your classes/ids below -->
    .warning, .error, .updated {display:none !important;}
    } 
  </style>';
}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.