Best Free – How to hide WooCommerce in dashboard menu for any role

advert

Learn how to hide “WooCommerce” button in your dashboard menu and leave product button that can be used to add product in the store.

You have an ecommerce website and you have added user on different role of and want to hide WooCommerce button on you ecommerce website.

hide WooCommerce in dashboard menu for any role

You can use WordPress’s ‘remove_menus()‘ function to do this. You can see that they are allowed to see the WooCommerce admin menu here: ‘/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-menus.php’

Look for: $main_page = add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'manage_woocommerce', 'woocommerce' , array( $this, 'settings_page' ), null, '55.5' );

How to hide WooCommerce in dashboard menu for any role YouTube Tutorial.

To stop this admin menu item from displaying for anyone but an Administrator, add this to your functions.php file or plugin:

add_action( 'admin_menu', 'remove_menus' );
function remove_menus(){

    // If the current user is not an admin
    if ( !current_user_can('manage_options') ) {

        remove_menu_page( 'woocommerce' ); // WooCommerce admin menu slug

    }
}

With the code you will be able to hide WooCommerce button from your dashboard for other role.

You may also like to read: [Best Free way] Change WooCommerce order status after X time has passed

advert:

Support us:

1
0
Would love your thoughts, please comment.x
()
x

Login To Access Code Snippet:

Stay UpTo Date with Latest Post And news: