I would like to create a View that displays users associated with a certain nid.

Under contextual filters, I have checked Content: Nid and selected

Provide a default value - Content ID from URL

Under Relationship, I have selected

Entity Reference: Referencing entity

Then under Fields, I have selected

(User referencing Content from field_office) User: First Name (First Name)
(User referencing Content from field_office) User: Last Name (Last Name)

But nothing is being displayed when I type in my nid into Preview with contextual filters

Essentially what I am trying to do is perform the following query:

$args = array(':nid' => $node->nid);
  node.title AND node.nid = :nid', $args);

I have done this before, but accidentally deleted the View. Now I am unable to make the View again, thought the DB structure has not changed at all.

Could someone please point out what I'm missing?

  • Can you explain the way your content is set up? It seems from this that you have a node reference field on your user entities. Is that correct?
    – goron
    Commented May 24, 2012 at 22:41
  • @goron - You are correct, I do have an Entity Reference field for my users which point to a specific Office node.
    – chlong
    Commented May 25, 2012 at 14:21

1 Answer 1


It seems to me that since your node reference field is on your user object and you want to list users, all you have to do is:

  • create a view listing Users
  • add a contextual filter corresponding to your entity reference field. The entity reference field on the User should appear in the contextual filters list. Choose that one.
  • Choose where the contextual filter value is coming from. If your view will be at myview/nid, where nid is the node id you want to use to filter, then you don't need to choose any other behavior. If you'll be displaying this view on a node page, use the default->content id from URL option.
  • Choose your user name fields without relationships. There is no relationship needed unless you need to bring in fields from the node being referenced.
  • thanks for that goron, but I am not having much luck with that. First I did "Add new View" and selected "Users" from the drop down (This only displays the 'root' user and nobody else). I then followed your steps but when I added 'User: Uid (Uid)', under 'Fields' and typed a nid into 'Preview with contextual filters:', the uid associated with that node did not appear. I can confirm that this nid does indeed have users associated with it. Would you have any other suggestions?
    – chlong
    Commented May 30, 2012 at 15:24
  • Hm. The first thing that's worrying me is that initially you only see user 1 in the preview. The view should show all users before you add the constraints above. Can you see if there is something that's causing only the root user to appear? Are your other users active? There's a filter on new user views by default that filters out blocked users.
    – goron
    Commented May 30, 2012 at 17:40
  • ah yes I see they are all indeed blocked...I will have to find a way to programmatically unblock them first!
    – chlong
    Commented May 30, 2012 at 17:47
  • You could also, for the sake of testing the view, remove the filter for active users.
    – goron
    Commented May 30, 2012 at 23:43

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.