I have a custom block and I want to limit it only to one role. The position of this block is administrator->dashboard.

I have set the visibility settings of block to be shown only to role editor, but when I sign in with a user whose role is something else, such as a photographer, it shows the block with a text in it: "(empty)".

It truly does not show any content, but I WONDER why it shows the block's structure? I expect it to be totally invisible as if no such block ever exists.

What's wrong with it?

  • What is the actual content of the block (what get's shown to a user with role photographer)? Is it like a View formatted as a block? Something else? In orde words: where does that content come from? And what is the test filter you are using in the block? Jun 14 '15 at 12:20
  • and what permissions does 'photographer' have? do they have bypass access control? or anything else that would cause the block to show. Can you show the code for the block?
    – Geoff
    Jun 14 '15 at 12:32
  • @Pierre.Vriens it is a block of Views, and its contents are a list of workflow-related posts. I have set also a Role-based access control in the Views settings which means I have set two-times of role-specific visibility restriction (with the block's own configuration). Jun 14 '15 at 12:41
  • Note that it is shown OK for the role which should be shown, and its content is prohibited where it should be; the problem is that the block's bounding box is shown for the prohibited roles. There is no content (except title) shown to the prohibited roles, but I wonder why it should ever even show the bounding box when it is totally illegal. Jun 14 '15 at 12:52

From the question details (and comments to it), it appears to me that the "(empty)" is somehow the result of your Views output (formatted as a block).

But for anybody who has not the role of Photographer, the result of the View (the output of it) is just "empty". So you may want to try / experiment with the "No Results Behaviour", which is located in the most right column when editing the view details (within 'Advanced').

Also note that you should make a difference between "access" to the content of the nodes (or whatever) that are shown in the block (if not empty), and what Drupal shows as the wrapper/container of such list (such as the block your question is about). Maybe, just for debugging purposes, you should try to build a similar view formatted as a page (instead of a block), and see what kind of output (result) you get in both scenario's (somebody with the photographer role, and somebody who des not have that role). While doing this page-related experiment, you may get different results, depending on what you specified within the "No results behaviour". And that might help to understand that your (empty) block issue is also a matter of "No result behaviour".

If you cannot get it to work this way, you may want to consider using the BEAN module, which gives you way more granularity / flexibility for creating blocks.

  • It has nothing to do with the content. because it DOES NOT show the content to prohibited roles. My problem is that why it shows the bounding box of the block at all? My problem is with the block's bounding box. Jun 14 '15 at 12:59
  • I think I understand what you wrote in your last comment, and updated my answer to better explain that "No result behaviour". Curious to hear if that might help ... Jun 14 '15 at 13:09
  • I created a simple text block, and exactly the same thing happens... Jun 15 '15 at 7:20

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.