1

I'm trying to show user info in node where this user name is set in User reference field.

I have content type where is User reference field (field_customer).

I have Views:

  • Show: Users
  • Contextual filter: (field_customer) Content: Customer
  • Relationship: User: Customer (field_customer) - reverse

In Contextual Filter I have: When the filter value is NOT available = Provide default value User ID from URL
In Relationship I have: Require this relationship

And I have fields like User: Email, User: Name etc.

I created node and set one user to User reference field.

Views does not work as it should. It shows all users. I tryed to play with Views settings but just could not find proper settings.

What I am doing wrong here?

EDIT

I also created another Views.

  • Show: Content
  • Contextual Filter: Content: Customer
  • Relationships: Content: Customer

In Contextual Filter I have: When the filter value is NOT available Hide view
In Relationships I have: Require this relationship

And it shows nothing on node page. Also tryed with different settings but no luck.

8
  • Just to clarify, is your "user reference" field actually an entity reference field that references users?
    – Chapabu
    Mar 25, 2013 at 18:43
  • It is User reference field type, not Entity reference field. It should be Entity?
    – hene
    Mar 25, 2013 at 18:52
  • If it's not too late to change your fields, I would strongly recommend moving over to Entity Reference. It should allow a backwards relationship in Views so you can easily get "entities referencing users" :-)
    – Chapabu
    Mar 25, 2013 at 18:54
  • I just made Entity reference field to reference user and modified my views but still not working. This is odd.
    – hene
    Mar 25, 2013 at 19:02
  • It sounds like your filters are wrong. If you're displaying this on a node page, and you've set the View up to get the User ID from the URL, you'll actually be passing the NID into the view as the UID.
    – Chapabu
    Mar 25, 2013 at 19:19

1 Answer 1

1

It sounds like you need to reference the relationship you created down in the filter criteria. In the example below I have a views where I want to display all documents of the current logged in user.

  1. I created the views showing all documents first. Get your view working the way you want it too first.
  2. Create the relationship - I want documents that are related to who authored them
  3. Filter your view by the author relationship. So in the example below my view is filtered by the current user - and it shows all documents in which the current user is the author.
  4. Once your view is sorted you can work out the user reference part.

Hope this helps

Documents View

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.