You are here

function role_theme_switcher_init in Role Theme Switcher 6

Same name and namespace in other branches
  1. 5.2 role_theme_switcher.module \role_theme_switcher_init()

Implementation of hook_init()

File

./role_theme_switcher.module, line 6

Code

function role_theme_switcher_init() {
  global $user, $custom_theme;
  foreach ($user->roles as $id => $role) {
    $role_theme = variable_get('role_theme_switcher_' . $id . '_theme', '');
    if ($role_theme != 'Default') {

      // Change active theme in user object
      $user->theme = $role_theme;

      // Also change the active theme globally
      $custom_theme = $role_theme;
    }
  }
}