1

I have two user roles that have term reference fields tied to profiles. One has a single select (user role A) and the other a multi select (user role B), but they reference the same taxonomy.

I have a view that lists all nodes of type C submitted by various users with a single user reference to user role A. My goal is to filter this to those with a user reference who has a term reference in common with a user of role B. The view is accessed by visiting user B's profile page and displayed as a block.

My thinking was to first add a relationship to the single select taxonomy term reference for role A. Then, add a contextual filter that loads the user id from the current URL and puts all the term IDs from the multiselect into the arg, for example 3+5+9. Finally, I would do custom PHP or Taxonomy term validation to see if user role A is in this list.

Setting the argument works fine. I can dsm this and see the correct TID. For validation, custom PHP doesn't seem to work at all. No rows are returned even when I simply do a "return true;" in there. For taxonomy term, I have it set to

  • Validator: Taxonomy term
  • My vocab is checked
  • Filter value type: term id
  • Action: no results found

Any idea what I'm doing wrong or the correct way to solve this problem?

EDIT: There was a problem with htaccess which explains why return true was failing. However, I still can't quite get the contextual filter and relationship logic down.

1

I can try this on a view, but I think the way to do it is to add the relationship, then add a Contextual filter of the Taxonomy Name. That works

enter image description here

with one Relationship to Contextual Filter, so why wouldn't it work with two.

enter image description here

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.