When users register they associate to one or more locations via user profile. Location is a custom content type. I have a custom field in the user profile defining a relation to this location.
I have a user-type view that returns un-authenticated users and is restricted to elevated role users. I’d like to add a filter that only returns un-authenticated users whose associated location value(s) match one or more location values from the current user requesting the view.
I can filter by the associated location, but I can’t relate that value to the current user’s value(s). I feel like I might be able to do this if I could add the current user uid to the relationships area and not just the contextual filters area. Can I do this without resorting to a custom filter or relationship?
EDIT:
There may be some confusion so maybe this will help clarify.
User -> Profile -> Location is the data association chain. I want to only show users whose Location value(s) match those of the currently logged-in user.
User (any) -> Profile (Student) -> Location(s) == User (current) -> Profile (admin) -> Location(s)
I could write SQL to do this but it’s not clear if this is possible to do using views alone, or if I need a custom relationship or filter.
The only way to do this within views is the following:
Use the following code:
Using PHP in this manner, you can load the current User and get associated values to filter by. This may be useful in many other contexts and circumstances.