Views listings are made from many users, but some of them have special role that is more important. Is there an easy way to give that special role different background color or font or font size when viewing views results ?

2 Answers 2


In your theme template.php file add this function

function THEMENAME_preprocess_html(&$vars) {
  foreach($vars['user']->roles as $role {
    $vars['classes_array'][] = 'role-' . drupal_html_class($role);

This will add the current role(s) to the body classes.

Now you can style it like this

body.role-admin .view-VIEW-CLASS {
  background: #eeeeee;
  font-size: 16px;

You could use a module like this https://www.drupal.org/project/views_table_highlighter .

It would take some php coding, inside views.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.