I want to apply a separate theme for each user role. I know there is option to do this from the admin side, but I want to do this programmatically.
I found an option using global $custom_theme. I changed my code as
function mymodule_config_preprocess_page(&$variables) {
global $custom_theme;
$custom_theme = 'bluemarine';
init_theme();
}
But it is not affecting the theme .Is this required any modifications?
Pls help me
I think it’s too late to change the theme at the point of preprocessing variables, you’ll probably want to do this in
hook_init():As far as I know there’s no need to call
init_theme()as Drupal will do this for you later on in the process, using the global$custom_themeto decide which theme to use.