3

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

5 Answers 5

4

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.

4
  • 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. Commented Nov 10, 2015 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'); Commented Nov 10, 2015 at 16:58
  • Great, I've updated the code! Please mark my answer as approved. Commented Nov 10, 2015 at 17:38
  • Please @NizamUddinSikder mark Adrian_Spiac as the correct answer to help others without wasting time. Thanks.
    – ken4ward
    Commented Jul 25, 2020 at 15:44
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; }";
}
1
  • It will hide notices & warnings for all non-admin users Commented Jan 14, 2016 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>';
}
}
0

Try this one

function am_disable_admin_notices() {
global $wp_filter;
if (!current_user_can( 'manage_options' )) {
    if (isset($wp_filter['user_admin_notices'])) {
            unset( $wp_filter['user_admin_notices']);
    }
}
add_action( 'admin_print_scripts', 'am_disable_admin_notices' );
0

I found the best solution on Kingsta. I prefer do not interfere to admin CSS.

// Hide dashboard update notifications for non-admin users function kinsta_hide_update_nag() { if ( ! current_user_can( 'update_core' ) ) { remove_action( 'admin_notices', 'update_nag', 3 ); } }

add_action('admin_menu','kinsta_hide_update_nag');

Source: https://kinsta.com/knowledgebase/disable-wordpress-update-notification/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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