Home > other >  How to remove bulk actions from admin orders page
How to remove bulk actions from admin orders page

Time:05-08

I'm trying to remove all default bulk actions from the admin's orders page with the following code:

add_filter( 'bulk_actions-edit-shop_order', 'remove_order_statuses_bulk' );
function remove_order_statuses_bulk ( $bulk_actions ) {
    error_log( print_r( $bulk_actions, true ) );

    $unwanted_actions = array( "mark_processing", "mark_pending", "mark_on-hold", "mark_completed", "mark_cancelled", "mark_refunded", "mark_failed" );

    foreach ( $unwanted_actions as $action ) {
        if ( isset( $bulk_actions[$action] ) ) {
            unset( $bulk_actions[$action] );
        }
    }

    return $bulk_actions;
}

The error_log shows the array containing just "edit", "trash" and "mark_custom-status" (which is a status that I've created using the same hook). So the array is already empty.

The problem is that the menu with bulk actions in wp-admin/edit.php?post_type=shop_order is still showing the removed entries.

I have no caching plugin at present. What may be causing this?

CodePudding user response:

Your function is being called too early since you don't have a priority set.

Change the priority of your add_filter and it works.

add_filter( 'bulk_actions-edit-shop_order', 'remove_order_statuses_bulk', 40, 1 );
  • Related