2

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

Finally found an answer, described in detail here. Confusingly, it starts with creating a view for displaying users. Use a contextual filter to limit it to the currently logged-in user. You can then create a relationship to bring in information about the custom user field, and a second relationship to find nodes that share the value from that field. 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, privacy policy and cookie policy

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