How can I remove the “bulk actions” based on user roles or capabilities.
Actually I have this code to do the job, but now I need to exclude the site admin, I need to let the administrator to access the bulk menu
add_filter( 'bulk_actions-' . 'edit-post', '__return_empty_array' );
add_filter( 'bulk_actions-' . 'upload', '__return_empty_array' );
How can I exclude roles or capabilities from that filter ?
I would do this this way – Just add a new mu plugin or normal plugin:
this will check if current user is Editor or admin – if not then bulk actions will be removed. For more about Roles & Capabilities look here in the Codex.