1

I am trying to display a few views blocks on nodes of authors that have specific roles. So far I used contextual filter Content: Author uid with the following settings:

Provide default value: User id from url (Also look for a node and use the node author checked) Specify validation criteria: validator user, Restrict user based on role checked and I checked the roles for which I want the block to show up.

Although it seems to work with some blocks, it does not with all.

A good example is this page. The Featured listings block has the same settings (contextual filter as described above) as the Similar listings one but it does not show up. I used the same filter for another page (diff role of the author) with exactly the same config except the role and seems to work fine as well.

Any idea anybody how this could work for all use cases? Is content author uid the correct filter and is the setup correct?

Any help will be much appreciated.

THanks

  • U can use php code in block settings to choose on what pages it should be displaying. But first you need to enable PHP module. Another step is to find how to check user roles. – ar7max Aug 26 '15 at 23:28
  • Adding php code is my last resort. I believe the views contextual filters are enough to do the job. Got it working for three blocks but only one is not working (although it has the same filter configuration) and want to make sure that I have done the correct configuration/selection of filter. If you check the above links you will see that similar listings, About this member and more from this member work fine. Only the featured listings blocks is missing from the node where the similar listings appear. In any case, thank you for the advise. – MariosK Aug 27 '15 at 15:20
  • Another thing is views_php module, it allows you to write code for checking user access for whole view – ar7max Aug 28 '15 at 10:03
1

Change access settings from access:Permissions to access:Roles and select the desired roles you want.

And for users use the contextual filters.

enter image description here

  • Thank you for your reply. This is not what exactly I am looking for. I want these blocks to be visible to everyone. I just want them to be hidden when the node author is of a specific role. For example I want to hide some blocks and show some other when the node author is of a specific role. A node authored by a premium user(role premium) should have certain blocks and the simple user (role agent) would have other blocks on the sidebar. Hope that helps more. – MariosK Aug 27 '15 at 13:41

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.