I have a vocab called "state of residence" with states in the form of TN, MS, AL, etc. Each user account has one of these references to show the state of residence. I can also place this taxonomy field on a forum post. But how can I make the post pull the "state of residence" term from the account of the user who has created it? I don't want the user to have to choose. I want the choice to be made automatically based on the user's account.

Or is there a better way than a vocab. Basically, I am trying to allow content to be sorted by the geography of the user who created the post. and I don't want the user to have to make the choice.

  • Do you want this sorting of the content at some listing made by views(I mean forum post listing is made by views) ?
    – RajeevK
    Jun 26, 2013 at 18:47
  • i will use views to sort the content, yes.
    – PJ McGhee
    Jun 26, 2013 at 19:45

1 Answer 1


This sort of thing is generally handled through contextual filters in your view. Views, Panels and Page Manager work well together to manage passing contextual filters to a view for filtered output, but there is a bit of a learning curve involved.

I'm not generally one for video tutorials, but I found this one to be a good introduction to this methodology: http://drupalize.me/videos/overview-page-manager-series

If you want a quick-and-dirty way to achieve this, use the module views_field_view https://drupal.org/project/views_field_view and do something like this:

  • in your forum posting view, set a contextual filter on your state term reference field tid

  • create a new view based on users, and add a contextual filter on "User: Uid"

  • on the contextual filter configuration page, under "when the filter value is not available" select "provide default value"
  • under type, select user id from logged in user
  • add a field for the state term reference field tid

  • add a field Global:View ( provided by the views_field_view module ), with these settings:

  • View: your forum postings view, as modified with contextual filter above
  • Display: Master
  • Contextual filter: [tid]

This should now display all forum postings whose state of residence matches the currently logged in user's state of residence.

note that if you are on a page URL that points to a profile of a different user, and you've set it up so the view is visible on this page, it will show all postings for THAT user, as the view will be able to grab a uid from the URL. ... so ... that may be a benefit or a drawback, depending on your intent.


disclaimer: written on short sleep. hope i got all the i's dotted and t's crossed

  • Thanks so much for the info here. I'm going to take a good look at your suggestions. i had been approaching this from the organic group perspective but I keep thinking that OG has more than what I need for this. Contextual filters is the way to go. Thanks so much for this answer. I love Drupal but sometimes I think that it is hard to see the forest for the trees because there are just so many ways to do things.
    – PJ McGhee
    Jun 27, 2013 at 17:39

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.