Not sure what I'm doing wrong here, seems pretty straight forward with what I'm suppsed to do, so that's why I think there is a coding error.

I have created a content type with a role reference field. I have created a handful of test pages assigning different roles for each page. The I created a new views block and everything was going smoothly until I tried to create a contextual filter using this role reference field.

I selected "Content: User Roles" and then "Provide default value" and "User Roles IDs from logged in User" assuming that would do the trick. But as soon as I select that, everything in the preview disappears.

Any help would be greatly appreciated. I am not a PHP wizard by any means but I am very comfortable with View and using contextual filters. I have been using Drupal for about 5 years, so I have already checked all of the simple mistakes and now I'm thinking there is something more major going on here.

**Screenshots Included**

Comments

kumkum29’s picture

Hello,

I have the same problem, I don't see how to configure the contextual filter of my view with this field.
Have you found a solution?

Thanks for your help.

kumkum29’s picture

Hello,

I have found a solution with a php code in the contextual filter:

global $user;
$rids = array_keys($user->roles);
$roles_ids = implode('+', $rids);
return $roles_ids;

...and select the "allow multiple values".

alex liannoy’s picture

Status: Active » Fixed

Hi guys,

Default arguments plugin already contains the code from the comment above:

    global $user;
    $rids = array_keys($user->roles);
    return implode("+", $rids);

I suppose, we can close the issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.