Restrict delete orders
-
Hello,
I want to restrict and deactivate the “Move to trash” action from bulk action on all orders page and “Move to trash” link on single order page for all users except for admins. I tried this code that normally works for whatever role we put on get_role() but it did not work. Plus I want to apply it to all users except for admins. It also be great if these actions are hiddent to prevent any delete.
Thanks.
function test_remove_shop_manager_capabilities() { $shop_manager = get_role( 'shop_manager' ); // Target user role //List of capabilities which we want to edit $caps = array( 'delete_shop_orders', 'delete_private_shop_orders', 'delete_published_shop_orders', 'delete_others_shop_orders', ); // Remove capabilities from our list foreach ( $caps as $cap ) { $shop_manager->remove_cap( $cap ); } } add_action( 'init', 'test_remove_shop_manager_capabilities' );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Restrict delete orders’ is closed to new replies.