I’m trying to apply automatically several filters to a view based on the corresponding profile fields selected by the current user.

For example, the users can select a favourite color (yellow, blue...) and a favourite food (fruit, meat...). If a user have selected that he likes "yellow" and "fruit", he should see in the view only the nodes that match both criteria (yellow fruits): bananas, lemons...

This is pretty easy to do when there's only 1 field to match (following the process indicated here), but this same process doesn't seem to work for matching several fields (the content field of the view only allows 1 relationship).

I've tried creating relations between relationships (like "chain relationships") and doesn't seem to work, but maybe I'm doing something wrong (I don't have a really deep understanding of how relationships work).

Any ideas? Maybe using the Relation or Entity Reference modules? Or some PHP code?

  • Somebody else can help me?
    – pedrogon
    Commented Dec 4, 2012 at 15:36
  • I've found two similar issues in drupal.org (drupal.org/node/562270 and drupal.org/node/557022) with PHP codes that should apply to my use case with slight changes, but my PHP knowledge is almost inexistent and I don't know what do I have to change exactly.
    – pedrogon
    Commented Dec 12, 2012 at 22:44

2 Answers 2


You should try chain relationship, this discussed here, similar problem to yours. Here the answer on similar question on drupal.stackexchange.

  • Thanks. I was aware of that thread (actually, I got the idea of using "chain relationships" from that particular answer of Merlinofchaos) but the problem discussed in that issue is quite different to mine and I don't know what do I have to change in order to make it work for my particular use case.
    – pedrogon
    Commented Nov 29, 2012 at 21:41

After many days of searching, testing and asking, I've finally found a solution here: http://blog.ampli.fi/filtering-a-drupal-7-view-based-on-multiple-user-profile-fields/#solution

  • Thank you so much for your answer. I had exactly the same problem and your answer has saved me many hours. My php skills are also not so great.
    – Ben
    Commented Nov 24, 2014 at 17:24
  • Please provide the solution here, not only a link. The link is dead by the way. Thanks
    – Yuri
    Commented Dec 7, 2016 at 21:54

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.