How do I hide from everyone but Super Admin the Woocommerce notifications about X Pro not being compatible and the Essential Grid activation?

How do I hide from a Shop Manager’s view, the nags warnings from Woocommerce notifying me that X Pro not being compatible? I have created a username for my client and I don’ want him to see ANY warning notifications and I hid all of the menu items I don’t want him to have access to. I added the code below to my “functions.php” file and it hid most of them but I still have 2 that I want out. The “Essential Grid” notification and the “Woocommerce” one. (See attached image)


add_action('admin_head','admin_css'); //using action hook to modify css
function admin_css()
{
if(current_user_can('shop_manager')) //check the current user role 
{
    echo '<style>';
        echo '.notice{display:none}';
        echo '</style>';
    }
}

~~~~~~~~~END CODE~~~~~~

<img src="//tco-forum-uploads.s3.amazonaws.com/original/2X/2/2997eeaa2c56a265772d901a07316933c31cb229.png" width="690" height="169">

I also used this code to hide from everyone except admin. I would prefer to have it this way so I know that none of these notifications are shown to anyone else.

CODE BELOW:

Hide from everyone but:

add_action('admin_head','admin_css'); //using action hook to modify css
function admin_css()
{
if(!current_user_can('admin')) //check the current user role which is not admin 

{
    echo '<style>';
        echo '.notice{display:none}';
        echo '</style>';
    }
}

Thank you!

Hi There,

Please change this code:

!current_user_can('admin')

To:

!current_user_can('administrator')

Let us know how it goes.

Hi Thai. Thanks for your quick response. Unfortunately, it didn’t work. What else would you suggest?

Thanks!

Hello There,

Sorry if it did not work out for you. Please make use of this condition instead:

if ( is_super_admin() ) {
  // do something
} else {
  // do nothing
}

- https://codex.wordpress.org/Function_Reference/is_super_admin

We would loved to know if this has work for you. Thank you.