Display user roles in Author Pane

Last updated on
30 April 2025

Edit your author-pane.tpl.php file and add the following code to display the users roles in the author pane.

Following has only be tested in Drupal 7, but it may work for Drupal 6.

<?php
// This will display all the users roles in a line separated by a , (comma).
?>
<div class="author-pane-line author-roles">
  <?php print implode(', ', $account->roles); ?>
</div>
<?php
// This will display all the users roles, except the 'authenticated user' role.
// This is not the best way to do this, but it works.
// The correct way should be to add a variable and use that variable,
// with the help you can find here: drupal.org/node/326809
?>
<div class="author-pane-line author-roles">
  <?php
    $roles = $account->roles;
    foreach ($roles as $key => $value) {
      if ($value == 'authenticated user') {
        unset($roles[$key]);
      }
    }
    print implode(', ', $roles);
  ?>
</div>

Help improve this page

Page status: Not set

You can: