I'm building a Drupal 7 site with a content type for events, and a view that displays a calendar of upcoming events. Events can be at one of two locations, and each user is also associated with one of the two locations. I'd like to set the calendar up so that the user only sees events for their location.

I tried doing this by creating a custom field on user profiles for location. However, I can't figure out how to use that field to filter the events on the calendar. It doesn't show up as an available value for contextual filters. Is there a way to do this?

Another option would be to make user location into a role, and then use role permissions to show the user one of two location-specific calendars. But this doesn't seem like what roles were really intended for.

Could I get some advice on an efficient way to do this? Events and user accounts are created by an administrator, and users don't need to be able to edit their location.

1 Answer 1


Finally I found an answer, described in detail on [SOLVED] Views - Filtering nodes by current user profile field, in the comment by Itangalo.

  • Create a user view.
  • Add a contextual filter on user: uid. If no filter value is present, build a default value using the currently logged in user. (This will give you exactly one user object in your view -- the logged in user.)
  • Add a relationship, using the relevant taxonomy reference field on the user accounts. This will bring you information about the "interest" term for the logged in user.
  • Add another relationship, called "term: nodes marked with term" (or something like that). This will bring you information about all nodes marked with the interest term for the logged in user.
  • Either set the view to display node teasers, or select a number of fields to display.
  • Add a display as usual. Done!

Confusingly, it starts with creating a view to display users. You can then create a relationship to bring in information about the custom user field, and a second relationship to find nodes that share that field value. I tried this and it worked for me!

A more straightforward method is described a few comments earlier, but I haven't tried that one.

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.