I have an Entity reference field View with contextual filter with Logged in user ID . The result of this view could be seen by the user only if he/she added some data. That is fine.

I would like to use the same Entity reference field View, so that administrator can view all the results without any restriction.

How can we achieve this. Thanks for the help.

2 Answers 2


I'm not really sure why this works but anyways.. It seems to be what you want.

You'll need Views Contextual Filters OR.

In my test, I used the contextual filter for author UID. So your entity reference field would only shows nodes created by the current user.

  1. In your view, add the Content: Author relationship (don't check required) and Content: Author uid contextual filter (provide default: current user).
  2. Enable Contextual filters OR in Query settings under Advanced.
  3. Add a second contextual filter for Content: Author uid (provide default: current user)
  4. Under More at the bottom of the filter, click exclude.

When added this an entity reference field, normal users only see nodes they've created but as admin, I see every node on the site. Weird but it works.

  • Thanks. But when I create Entity Reference View, I cant see the Query settings under Advanced .
    – Gireesh
    Sep 2, 2016 at 15:29
  • Did you install the module? Sep 2, 2016 at 15:51
  • yes. and enabled.
    – Gireesh
    Sep 2, 2016 at 16:18
  • I can see the module in query settings when the view is normal. But NOT when its Entity Reference View.
    – Gireesh
    Sep 2, 2016 at 21:17

In Drupal 8 I was able to do this without any contrib module like contextual filters OR.

  1. add the Authored By contextual filter for your entity type
  2. choose provide default value... from logged in user
  3. below in the "when value provided" section select "specify validation criteria
  4. For validator select User ID
  5. check "restrict user based on role"
  6. select your NON-ADMIN roles
  7. for "Action to take if filter value does not validate" select "display all results"

So if viewed by the non-admins is will show only where the logged in user id matches the entity owner. For admins it will show all.

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.