Hi Norm! .. Could you mind trying this code?
add_action( 'plugins_loaded', 'my_conditional_themes_setup', 100 );
function my_conditional_themes_setup() {
//Switch to channel66 theme if user ID matches
Conditional_Themes_Manager::register( 'channel66', function() {
$current_user = wp_get_current_user();
return ( ! empty( $current_user ) && $current_user->user_login === '7ff6xi' );
} );
}
Awesome Nashwan! Thanks… that worked and I see what you are doing different than what I did. I’m not really sure why mine didn’t work, but I’m also not a php expert.
If you have the time, would you mind telling me how to make the two conditionals below OR’d? So that either condition can make the theme active. Each works as a standalone, but not if they are together. I thought the php ‘return’ statement would immediately return out of the function call when it evaluated to true.
add_action( 'plugins_loaded', 'my_conditional_themes_setup', 100 );
function my_conditional_themes_setup() {
//Switch to channel66 theme if user ID matches
Conditional_Themes_Manager::register( 'channel66', function() {
$current_user = wp_get_current_user();
return ( ! empty( $current_user ) && $current_user->user_login === '7ff6xi' );
} );
// Switch to channel66 theme if the visitor use Internet Explorer.
Conditional_Themes_Manager::register( 'channel66', function() {
global $is_IE;
return (bool) $is_IE;
} );
}
ps… I know this little php help is beyond the scope of your plugin 😉
You mean like this?
add_action( 'plugins_loaded', 'my_conditional_themes_setup', 100 );
function my_conditional_themes_setup() {
Conditional_Themes_Manager::register( 'channel66', function() {
global $is_IE;
$u = wp_get_current_user();
return ( $is_IE || ( $u && $u->user_login === '7ff6xi' ) );
} );
}