How to create a contextual filter using a current user multivalue field as the default value?

The idea is to filter content in a view, based on a value present in a multivalue field that the currently logged in user account has.

I tried using views php in the default contextual filter:

$user_profile = user_load($user->uid); $statusvalue= $user_profile->field_status['und'][0]['value']; return $statusvalue;

..but that works for a single value and thus does not work in my case.

2 Answers 2


In your contextual filter go to bottom and in tab "more" check "allow multiple value" checkbox and return value 1+2+3 (OR) or 1,2,3 (AND).

  • I tried that checkbox, but using my php code that doesnt work for me.
    – Yuri
    Commented Oct 28, 2017 at 14:09

Answering my own question: I accomplished this without using a contextual filter. The view can be based on entities. (Alternative solution is to use a user view, slightly different config)

I added the field two times, of which one uses the relationship to the user.

Then added the fillter 'global: field comparison' and selected both fields.

As a bonus I added a filter, using OR switch, to allow a specific user field value for showing all content.

enter image description here

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.