Removing WooCommerce Submenu Items
if ( is_user_logged_in() )
{
$current_user = wp_get_current_user();
if ( !($current_user instanceof WP_User) )
return;
if(user_has_role($current_user->ID, 'shop_manager' )
{
add_action( 'admin_menu', 'my_remove_sub_menu_pages' );
function my_ remove_sub _menu_pages() {
// the first parameter is the slug of the top menu item to be removed
// the second parameter is the slug of the sub-menu item
remove_submenu_page( 'admin.php', 'woo_ce.php' );
remove_submenu_page( 'admin.php', 'wc-reports.php' );
remove_submenu_page( 'admin.php', 'wc-settings.php' );
remove_submenu_page( 'admin.php', 'wc-status.php' );
remove_submenu_page( 'admin.php', 'wc-addons.php' );
}
}
}
if(!function_exists('user_has_role'))
{
function user_has_role( $id, $role )
{
// retrieves an array of roles
$roles = get_user_roles( $id );
if ( $roles && in_array ( $role, $roles ) )
{
// checks if specified role is listed
return true;
}
else
{
return false;
}
}
}