0

I have created View permission field in the events content type. Its field type is Role, so I can select which roles can see the node.

This works fine, but when I add events content type in the view this will displays all the data. I want to filter the data by the View permission field for the currently logged-in user.

I want to show data to the roles which I selected in the node View permission field. I have tried with contextual filter with user:uid, but I don't get what I am expecting. Actually, I don't know how to do that.

How can I achieve this?

Note: I want to integrate with my content type field View permission. I will select a role in View permission field. That roles only can see the view result.

6
  • Are you saying you have tried using contextual filter "Provide default value" >> "User ID from logged in user"? If not please try this.
    – RDP
    Commented May 18, 2016 at 6:58
  • I have tried this. Not working. Commented May 18, 2016 at 6:59
  • Welcome to Drupal Answers! Please don't add Drupal in the title: This Stack Exchange site is about Drupal, so there isn't the need to say it in the title. If it was about WordPress, the question would be off-topic for us.
    – avpaderno
    Commented May 18, 2016 at 7:18
  • Just to make it explicit: Are you using Drupal 8 or Drupal 7?
    – avpaderno
    Commented May 18, 2016 at 7:30
  • The OP is saying the roles users should have to see the node is in a field of the node itself. That contextual filter would filter the nodes by the author, but it doesn't check the current user has the necessary role. – kiamlaluno♦ I still don't get, but hopefully someone else will.
    – No Sssweat
    Commented May 18, 2016 at 7:42

1 Answer 1

0

It sounds like the only requirement here is a per-node, role-based, permission setting on content. If that's the case, I'd drop your role reference field in lieu of Content Access. The module enables such a requirement and it hooks deeper into the Drupal permission system so you don't have to build a bespoke permission checking for every situation (e.g. views access, node page access, etc.).

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.