Fix for User roles as body classes

  1. **
  2.  * Override or insert variables into the page templates.
  3.  *
  4.  * @param $vars
  5.  *   An array of variables to pass to the theme template.
  6.  *
  7. */
  8. function phptemplate_preprocess_page(&$vars) {
  9.   // to have user roles as body tag classes
  10.   global $user;
  11.   foreach ($user->roles as $id => $rolename) {
  12.     $roles .= ' ' . str_replace(' ','-', $rolename);
  13.   }
  14.    // we put the current user's roles in our body tag classes below
  15.   $vars['body_classes'] = $vars['body_classes'] .  $roles;
  16. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.