I have a standard Drupal installation with Views and Administration Views modules installed.

By default, the Users view has a column Roles with ALL the users roles.

How to include a custom column (to replace the default Roles column) to show if the user has or hasn't a specific role (like a yes/no column)?

  • Can you be more clear as there is already a column Roles, and you can also filter by an exposed filter on Role – J. Reynolds Aug 12 '14 at 19:05
  • Hi Reynolds, I edited the question to be more clear. I don't need (now) to filter rows, only show a yes/no for a specific role. – Eduardo Leggiero Aug 12 '14 at 19:55

I don't see an out of the box method. Maybe someone else will have a better answer. But what I did for a quick solutions is to add the Views PHP module, then add a PHP field with the following output code:


  $account = user_load($data->uid);

  $roles = array('YOURROLE', 'ANOTHER ROLE');

  if (count(array_intersect($roles, $account->roles))) {
    print 'Yes';
  else {
    print  'No';


It will print yes if any user has either of the two roles.

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.