I have a view where I list user's own contents, this contains bulk operations. Users with "add article" permission can see this bulk operations thing but I would like to hide this bulk operations "form element" / "functions" for users in employee role.

How can I do this?

enter image description here

  • did you try going to /admin/people/permissions ?
    – No Sssweat
    May 3, 2016 at 8:07
  • Yes, I tried but I cannot hide bulk operations "elements" there.
    – asrob
    May 3, 2016 at 8:18

2 Answers 2


To remove the bulk operations "form element" use ViewExecutable->removeHandler in hook_views_pre_view():

use Drupal\views\ViewExecutable;

 * Implements hook_views_pre_view().
function rgr_main_views_pre_view(ViewExecutable $view, $display_id, array &$args) {

  if ($view->id() === 'content') {
    $account = \Drupal::currentUser();
    $is_employee = in_array('employee', $account->getRoles());

    if ($is_employee) {
      $view->removeHandler($view->current_display, 'field', 'node_bulk_form');

This will hide the dropdown form elements, the checkbox in the row and the submit buttons.

  • This works as expected, but note that it requires use \Drupal\views\ViewExecutable; or you're going to get an error like Argument 1 passed to hook_views_pre_view() must be an instance of ViewExecutable - and this function also takes more than one parameter. See hook_views_pre_view()
    – komlenic
    Dec 13, 2018 at 19:44

You need to set the appropriate permissions for the employee role.

What you need to look for is not views bulk operations permission, or similar, what you really need is to uncheck the permissions related to nodes.

So if you uncheck the permissions for adding, editing and deleting content, then those bulk operations should be gone as well.

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.