what i need

I am using a wordpress theme which supports woocommerce,
when adding a user with shop manager role i don’t want to show the woocommerce menu.

Just need the products menu only.

please help.


Solution:

You can use WordPress's 'remove_menus()' function to do this.

Store Managers have a capability: 'manage_woocommerce'

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' );

So much for the theory. 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
    }
}

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: