Hi,

I created a content type - admin and customrole have access to view. Content type has entity reference field.
I added two users. Both users are members of customrole.
Add content > entity reference = user1 > node/1.
Add content > entity reference = user2 > node/2.

When User1 logs in, he should have only view access to node/1. No access to node/2.
When user2 logs in, he should have only view access to node/2. No access to node/1

Admin should have access to both nodes.

I can do it using view. I am talking how I can do in node level?

Thanks.

Comments

edukates’s picture

dev18.addweb’s picture

Yes, It can done by contextual filter in views.

Views configuration steps:

1. Create a view as required.
2. Add contextual filter "Content: Author uid" and mark on "Provide a default value" on WHEN THE FILTER VALUE IS NOT IN THE URL" and set value User ID from logged in user"
3. Also add EXCEPTIONS on right hand side and "Exception value" = '1' (which says when admin logins, author uid condition will be skipped)

Thanks!