Remove bulk actions based on user role or capabilities

I would do this this way – Just add a new mu plugin or normal plugin:

<?php
defined( 'ABSPATH' ) OR exit;
/** Plugin Name: Limit Bulk actions to Editor & Admin */

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

    if ( ! current_user_can( 'delete_others_pages' ) )
    {
        add_filter( 'bulk_actions-edit-post', '__return_empty_array' );
        add_filter( 'bulk_actions-upload',    '__return_empty_array' );
    }
}

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.

Leave a Comment