I have a plugin that I’m using to switch themes for a specific user for development. When logged in as that user they see the different style sheet but the themes files, function.php, header.php, etc are the active theme for everyone else.
What I am doing wrong?
function change_user_theme($template) {
global $user_ID;
if ( in_array( $user_ID, array( 5 ) ) ) {
$template = 'fezmobile';
} else {
$template = 'fezforprez';
}
return $template;
}
add_filter('template', 'change_user_theme');
add_filter('stylesheet', 'change_user_theme');
add_filter('option_template', 'change_user_theme');
add_filter('option_stylesheet', 'change_user_theme');
Take a look at my answer here:
Switch Theme Through Options Panel
The code is as follows:
You have to swap the template and stylesheet on the
setup_theme
action.I actually found a better solution, but only after marking the answer above, as the answer.
Using this code instead of the one supplied by @sanchothefat, functions like:
Will now work correctly.