My WooCommerce version is 4.5.2.
I will like to remove the 'Add order' for a custom user so that it cannot access wp-admin/post-new.php?post_type=shop_order
.
I have created a custom user using User Role Editor with the following permissions:
With this, the user can only view existing orders, and click the order preview to update to 'Completed'.
I tried using this:
remove_submenu_page( 'edit.php?post_type=shop_order', 'post-new.php?post_type=shop_order');
...but the Order main menu becomes not accessible.
I came across this post Remove or hide "add new" button on woocommerce on bulk order panel, which hides the 'Add order' from the page using CSS.
I wish someone can point me to a direction on how to achieve what I am looking for.
UPDATE:
Based on 7uc1f3r's answer, this is my output
[edit.php?post_type=shop_order] => Array
(
[5] => Array
(
[0] => Orders
[1] => edit_shop_orders
[2] => edit.php?post_type=shop_order
)
[10] => Array
(
[0] => Add order
[1] => edit_shop_orders
[2] => post-new.php?post_type=shop_order
)
)
Using the provided solution, I use this so that the custom user cannot Add order and access wp-admin/post-new.php?post_type=shop_order:
unset( $submenu['edit.php?post_type=shop_order'][10][0] );
unset( $submenu['edit.php?post_type=shop_order'][10][1] );
unset( $submenu['edit.php?post_type=shop_order'][10][2] );
In addition, I apply CSS to hide the 'Add order' at the admin panel:
ul.wp-submenu.wp-submenu-wrap {
display: none !important;
}
It now looks like this: