X launch button in dashboard

Hi Ive updated my theme and now there’s a x button in my user dasboard.
Is there any way to remove this for non-admins ?

thanks

Hello There,

Thanks for writing in! Because what you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

After the child theme is set up, please add the following code in your child theme’s functions.php file

// remove X launch menu in the WP admin bar
// =============================================================================
add_action( 'wp_before_admin_bar_render', 'remove_x_menu', 99 );
function remove_x_menu( $wp_admin_bar ) {
  global $wp_admin_bar;
  if( ! current_user_can('administrator') ){
    $wp_admin_bar->remove_menu( 'cs-main' );
  }
}
// =============================================================================

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

It does’nt seem to work :frowning:

Hi,

I tried the code and it works on my end.

Please note that it will not show for non-admins only.

Maybe you are login as admin?

Kindly double check.

Thanks