Hey there,

is there a way for me to filter a view by the current user in a userreference field? I have a custom content which allows the author to list all users whom he wants a response from for a given content. So my CCK content type has a userreference field for that. However, I can't get Views to list out those contents to a user in the form of a block. Any ideas?

Thanks

Comments

merlinofchaos’s picture

Project: Views (for Drupal 7) » Content Construction Kit (CCK)
Version: 6.x-2.0-alpha4 » 6.x-1.x-dev
Component: Code » Views Integration

This is a CCK question.

changed’s picture

Oops...posting up the wrong tree :-P...Thanks.

karens’s picture

Yes, using Views 2 and D6 CCK you can do that. Create a view and add the userreference field to it and you'll see the usernames listed in the view. For even more fun, add a relationship to the view and indicate you want the relationship to be the userreference field, then add any user field you want and you'll see a drop-down asking you if you want to get user info from the relationship. Say yes and you can see anything about that user you want to see.

karens’s picture

Status: Active » Fixed

Forgot to change status.

karens’s picture

Oops, now that I answered a bunch of questions you didn't ask, I am thinking maybe you are asking if there is a filter that will show only the current user's information.

That process is similar. Add the userreference relationship to the view. Add filter to the view for User: Active user. Then choose that the active user should come from the relationship.

changed’s picture

Sweet...Works great now. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

borgo’s picture

Thanks for the tip KarenS!

In case someone is following this, In #5 filter should be User:Current which is "Filter the view to the currently logged in user". User:Active is something else "Whether a user is active or blocked".

Works great.

ionmedia’s picture

thanks

dddbbb’s picture

Thanks borgo - was going a bit mental there...

THE ANSWER TO THIS ISSUE: a combination of #5 & #8.

felipesluz’s picture

Tank's "KarenS".... Good Bless you!!!

msathesh’s picture

Thanks for posting this. I was really breaking my head around the userreference and views to limit the user access. Thank you @karen.

Vidus’s picture

Just wanted to add my thanks. I've been wanting to do this for years, and just found this post. THANK YOU so much Karen