Skip to main content
2 of 5
deleted 47 characters in body
pixeline
  • 2.9k
  • 7
  • 34
  • 44

Display a different theme for not logged-in users

Based on answers like this one, I made a small plugin to display a theme displaying a "Coming soon" theme, whilst our team of editors can fill in the final theme.

It worked yesterday, but today, even though I'm logged in, I only see the "waiting" theme. I logged out and logged back in, but still, I'm seeing the "waiting" theme, as if the is_user_logged_in() function returned false. Are these hooks too early to check for user authentification?

<?php

add_filter('template', 'pxln_change_theme');
add_filter('stylesheet', 'pxln_change_theme');

function pxln_change_theme($theme) {    
    if ( ! is_user_logged_in() ) {
        $theme = 'waiting';
    }
    return $theme;
}
pixeline
  • 2.9k
  • 7
  • 34
  • 44