• Resolved zwalker

    (@zwalker)


    Hello,

    Just recently, I tried to use the passkey link to switch themes while not logged in. The cookies are being set but it doesn’t go to my other theme. I’m not sure why as it has always worked before and still works on my staging serve which is more or less exactly the same app wise.

    Another thing that happens is I cannot log in after using the link. I have to clear the cookies it sets first.

    Any help or direction is most appreciated.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Jeff Starr

    (@specialk)

    Glad to help, but not sure what might be happening. I can tell you that what you describe does not happen on default WordPress install. So that might be something to try, setting up a quick default WP and trying again with only Theme Switcha active. That will give you a baseline from which you can do further testing, like with your other plugins and so forth. This is just basic troubleshooting, I would be glad to provide a complete guide if it will be useful for you.

    Thread Starter zwalker

    (@zwalker)

    Hi Jeff,

    I figured it out. It’s a compatibility thing with the newest version of WP Rocket.

    I disabled this plugin specifically and everything worked. Do you have any insight into why this might be happening?

    I can exclude the theme-switcher cookies from the cache etc.

    Best,
    Zach

    Plugin Author Jeff Starr

    (@specialk)

    Hey Zach,

    No sorry I don’t use WP Rocket. If it were my own site though, I would examine the error/debug log(s) to get an actual description of what’s happening. That information would be super useful in determining the cause of the issue.

    Plugin Author Jeff Starr

    (@specialk)

    Hi @zwalker, just wanted to follow up with this. It’s been awhile with no reply, so I hope the issue is resolved? Or if there is anything I can do to help, please let me know. Thank you.

    Thread Starter zwalker

    (@zwalker)

    Hi Jeff,

    There was nothing of value in the debug / error logs and I couldn’t find a resolution so I ended up disabling WP Rocket and doing all the Caching / Optimisations programmatically instead.

    I do get a critical error on the site if I use the top bar to switch themes and then log out. Can you hook the log out routine and clear your plugin cookies?

    • This reply was modified 3 years ago by zwalker.
    Plugin Author Jeff Starr

    (@specialk)

    Hey Zach,

    Not sure about this:

    “Can you hook the log out routine and clear your plugin cookies?”

    It’s not something the plugin can do, but in general it may be possible.

    Thread Starter zwalker

    (@zwalker)

    You’re aware of this error related to the use of the plugin though? It’s something that would make the most sense to fix from the plugin’s code base in the next update.

    Something along these lines, maybe:
    <?php
    function theme_switcha_clear_cookies_on_logout() {
    unset($_COOKIE[‘theme_switcha_theme_’]);
    unset($_COOKIE[‘theme_switcha_pass_’]);
    }
    add_action( ‘wp_logout’, ‘theme_switcha_clear_cookies_on_logout’ );
    ?>

    Plugin Author Jeff Starr

    (@specialk)

    “You’re aware of this error related to the use of the plugin though?”

    Which error? So far I have not been able to replicate any error on default WordPress. If you can provide the steps to do so, it will enable me to investigate and try to resolve asap.

    For the clear cookies on log out, it is more complicated because some configurations enable theme switching regardless of logged status.

    Thread Starter zwalker

    (@zwalker)

    Theme settings are passcode view only while logged out.

    1) Log in
    2) Theme Switch to anther theme which is not current one used on the site (this will set theme_switcha_theme_ cookie)
    3) Log Out
    4) See error. (Due to no pass cookie being set)

    Happy to do a Loom if you’re unable to reproduce.

    You can fix by adding a extra condition when it looks at what theme cookies are set. Have it default to current theme if no pass cookie is set and settings are passcode view only.

    • This reply was modified 3 years ago by zwalker.
    • This reply was modified 3 years ago by zwalker.
    Plugin Author Jeff Starr

    (@specialk)

    Thanks.

    So I set the “Allowed Users” setting to “Only with Passkey”. Then I logged in and switched to some other theme. That opens another tab and the new theme is active. Then I return to the Admin Area and log out. Revisiting the front-end, I see no error. Logging back in and examining the site’s error logs, I see no errors, warnings, or notices.

    I guess I am confused as to where the error happens or is recorded? Also note that I am testing on default WordPress with no other plugins active.

    Thread Starter zwalker

    (@zwalker)

    Ahh I see… it’s theme_switcha_active_theme() is returning the theme switched theme on log out when passcode cookie is not set. I’m using this in my functions.php.

    Plugin Author Jeff Starr

    (@specialk)

    I don’t understand..?

    Thread Starter zwalker

    (@zwalker)

    I am using the theme_switcha_active_theme() function from your plugin core file to see what the current switched too theme is and include anything relavant to that theme in my functions.php.

    Right now, when logged out, this function is returning the switched too theme even if theme options / permissions don’t align.

    Is there another function here that I can use to check the options?

    if(function_exists(‘theme_switcha_active_theme’) && (theme_switcha_active_theme() == ‘my-switched-to-theme’)) {
    // DO important stuff
    } else {
    Do stuff for active theme
    }

    • This reply was modified 3 years ago by zwalker.
    Plugin Author Jeff Starr

    (@specialk)

    No but you might be able to write something that will do it. I’ll take a closer look at all of this for the next plugin update. At that point I can let you know more specific infos about what is and isn’t possible.

    Thread Starter zwalker

    (@zwalker)

    Awesome, thank you! I’ll see what I can do in the mean time.

    Best,
    Zach

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Theme Switcher sets cookies then stays on current theme’ is closed to new replies.