I want to remove bulk action for non admin user (shop manager to be specific), so I got this code that let me to remove the bulk action for all users.

add_filter( 'bulk_actions-edit-shop_order', '__return_empty_array', 100 );

How can I make it working only for the shop manager role users?

I also tried this, but it didn't work.


  • Out of curiosity, why? – Tom J Nowell Jan 25 '19 at 0:27
  • i got some workers that need access to the admin panel to call customers to confirm orders so every worker has a certain number of orders that he need to complete for the day before going home they used to send a lot of order to cancel without calling them so i needed to create a custom order status exmp : new order worker 1 cancelled worker 1 and i removed the bulk action he got only a button to send it to cancelled worker 1 hope that i explained well – Houssem Ghozzi Jan 25 '19 at 0:33

Here's how you can remove bulk actions for any user not an administrator.

add_action( 'wp_loaded', 'my_remove_bulk_actions' );
function my_remove_bulk_actions() {
if ( ! is_admin() )

if ( ! current_user_can( 'administrator' ) ) {
  add_filter( 'bulk_actions-edit-shop_order', '__return_empty_array', 100 );


If you would like to target just the shop manager you can edit the if statement

if ( ! current_user_can( 'administrator' ) )


if ( current_user_can( 'shop_manager' ) )

Tested and working on latest version of WordPress, 5.0.3 at time of posting.

| improve this answer | |

As per Codex:

While checking against particular roles in place of a capability is supported in part, this practice is discouraged as it may produce unreliable results.

It further stated:

Passing role names to current_user_can() is discouraged as this is not guaranteed to work correctly (see #22624).

Therefore, current_user_can() should not be used to check a user's role. It should be used to check if a user has a specific capability.

You may change the Shawn w code as follows:

// for all the non-admin roles
if ( ! current_user_can( 'manage_options' ) ) { ...

// just for the Shope Manager role
if ( ! current_user_can( 'manage_options' ) && current_user_can( 'manage_woocommerce' ) ) { ...
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.