• Resolved bluelee22

    (@bluelee22)


    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)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @bluelee22,

    For reference, these particular forums are meant for general support with the core functionality of WooCommerce itself. For development and custom coding questions, it’s best to ask for insight related to those on either the WooCommerce Advanced Facebook group or the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:

    I wish I could help more, but hopefully, this gets you going in the right direction to get some further insight/information.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @bluelee22,

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. Hopefully, you were able to find a solution to your problem!

    If you have further questions, please feel free to open a new topic.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Restrict delete orders’ is closed to new replies.