I have a View with several blocks or displays. In one of these displays I have added the filter "Published" and made it exposed, so that user can switch between published and unpublished content.

Now I only want users with the administrator role to be able to see this filter, but I cannot figure out how to do this. Can anyone give me a hint?

Thanks in advance

2 Answers 2


If you expose the filter as a block from within the view (Advanced - exposed form in block) then you could set the permissions on the exposed form block in the block system to Admin role users. Alternatively I can only think that you might need to use hook_form_alter to amend the permissions on that form if you want everyone others to see the view but not the exposed form.

  • Hello and thanks for your answer. The option 'Exposed form in block' requires the page display, and is not available for the block display. My view consists of 6 different blocks. There has to be a solution, but I still haven't found it.
    – TBJ
    Commented Apr 14, 2016 at 6:50

I post the answer myself in case anyone is having the same problem. The solution was to use views-view--display_name.tpl.php and simply add a check if the user is admin or not for the exposed item... like this:

<?php global $user; ?>
<?php if (in_array('administrator', $user->roles)):?>
  <?php if ($exposed): ?>
    <div class="view-filters">
      <?php print $exposed; ?>
  <?php endif; ?>
<?php endif; ?> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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