0

I'm trying to set up a View in Drupal (both as a page and a block) that can only be accessed by specific users. The goal is to ensure that only the user assigned to a particular "Person" content type can view this block.

Here's the setup: enter image description here

  • The Person field here is a reference field that links to another content type: Person.
  • Each Person is authored by a specific user.

What I'm aiming for:

  • I want the View to display content only to the user who is associated with that "Person".
  • Essentially, if a user authored that "Person", they should be the only one able to see the View page/block.

However, I’m having trouble figuring out how to configure this in Drupal. I've attempted a few relationships and contextual filter setups, but I haven't been successful. 😭

Can anyone guide me on how to set this up correctly? I’d appreciate any insights. Thanks in advance for your help!

Drupal version 10.4.0

4
  • Create a role. Give it a specific permission no other role has. Set the permission on the view to be for that permission. Assign the role to the user who should be able to see the view. Commented Jan 20 at 16:04
  • Have you set permission for the Person content type? If users only have permission to view Persons they create, then you don't have to configure the view; you can simply list all persons and Drupal will automatically exclude the persons the user does not have access to. Alternately, if you didn't set up permissions on the content type for some reason, you can add a contextual filter that checks whether the logged-in user is the author of the person. Commented Jan 21 at 1:57
  • @PatrickKenny Thank you so much for your comment. It turns out I haven't set a specific permission on my end. And it works now! Thanks again. Commented Jan 21 at 7:59
  • @Jaypan I’ve already created a role, but I realized I missed setting up the permission for that role to view the content. It works now. Thanks for the suggestion! Appreciate it. Commented Jan 21 at 8:00

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.