1

In addition to the Administrator role, I've created several roles. I'm still using the Administrator role for users who needs administrator access.

However, in my user list, I've created with Views, I'd like to hide the Administrator role, so it only displays the one role I've chosen instead of listing all the roles associated to the user.

I've already configured a filter criteria where I haven't included the Administrator role and only the roles I'd like to display, but Views disregards this and display the Administrator role.

My filter criteria configuration

You can see the members page here: You can see the list here: http://xpeek.dk/sas-members

I hope any of you can assist me in this.

Regards, Frederik

  • Somewhere in your filter you have to see "Limit list to selected items". Can you verify that? – Robin Feb 17 '15 at 12:52
  • Thanks for you answer! Unfortunately, I do not see "Limit list to selected items". I'm using Views v. 7.x-3.10 – hjorslev Feb 17 '15 at 14:13
0

I think you should use Views PHP module. here you can able to write custom code. May be it'll helpful to you. You want approx this kind of view?

enter image description here

For that you should try View Php Module. After that choose Global Php option in field tag and then write your code. I tried this may be it's not feasible, but here is the code.

In output section:-

<?php
$roles = array();
$user = user_load($row->uid);
$roles = $user->roles;
if (array_key_exists("7",$roles)) {
   // admin role has rid 7
   unset($roles[7]);
}

foreach ($roles as $key => $val) {
 echo $val."<br>";
} 

?>
  • Thanks, I didn't knew that module existed. However, since my PHP skills are quite basic, I'll see if I can find a solution that works directly with the core Views module. – hjorslev Feb 18 '15 at 15:24
  • Views Php Module work directly with the core views module. Once you enable this module. then in field section you get option "Global Php". – Rahul Seth Feb 19 '15 at 6:10

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.