Alireza Sabahi
Alireza Sabahi

Reputation: 675

how to create woocommerce only order manager access

I'm trying to create a role in my wordpress that could manage orders (edit, delete, read and change status)

I'm using user role editor plugin in my woocommerce,
also tried:

edit_shop_order
edit_shop_orders
edit_published_shop_orders
edit_private_shop_orders
edit_others_shop_orders
read_shop_order
shop_order
view_admin_dashboard
woocommerce_order_itemmeta
woocommerce_order_items
woocommerce_view_order

the problem is if i don't check manage_woocommerce there is no orders to display, but if I check it, all orders displays correctly bud woocommerce setting is also shown.
Can everyone help me by doing this programmatically or in user role editor plugin?

Upvotes: 0

Views: 510

Answers (1)

Alireza Sabahi
Alireza Sabahi

Reputation: 675

By adding this code you can disable other woocommerce setting menus and active only orders menu:

add_action( 'admin_menu', 'remove_menu_pages', 999);
function remove_menu_pages() {
global $current_user;

$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
  if($user_role == "orders_manager") {
    $remove_submenu = remove_submenu_page('woocommerce', 'wc-settings');
    $remove_submenu = remove_submenu_page('woocommerce', 'wc-addons');
    $remove_submenu = remove_submenu_page('woocommerce', 'wc-status');
  }
}

Upvotes: 1

Related Questions