Comment styling dependent on author's user roles I want to style comments differently depending of the author's user roles. How can i add a specific class attribute in the comment template if the author of the comment has a certain role?
I got it myself. Here is how to do it:

In your theme template.php:

function MYTHEME_preprocess_comment(&amp;$vars) {
    // user roles
    // 1 = anonymous user
    // 2 = authenticated user
    // 3 = administrator
    // ...
    $vars['role_classes'] = '';
    $sql = "SELECT users_roles.rid FROM {users_roles} WHERE users_roles.uid = " . ((int) $vars['comment']-&gt;uid);
    $result = db_query($sql);
    foreach($result as $record) {
        $roleId = $record-&gt;rid;
        if($roleId == 3) $vars['role_classes'] .= ' comment-by-admin';
    }
}


Then change in your comment.tpl.php

&lt;div class="&lt;?php print $classes; ?&gt; clearfix"&lt;?php print $attributes; ?&gt;&gt;


to

&lt;div class="&lt;?php print $classes; ?&gt;&lt;?php print $role_classes; ?&gt; clearfix"&lt;?php print $attributes; ?&gt;&gt;