Missing $current_user and $current_site globals when browsing mapped domain

I just noticed a strange bahavior while debugging an issue with the WP Maintenance Mode plugin.

WP Maintenance Mode allows you to set a user role that gets access to the site when it's activated. When I accessed the site via the mapped domain I was locked out. When I tried again using the original domain everything worked fine.

I had a look at the $current_user variable and it turned out it's empty. Same goes for the $current_site variable.

This would also explain why I don't see the adminbar when I'm browsing the mapped domain.

My goal is to only use the original domain for the admin + login/registration and the mapped domain exclusively for the frontend.

Can somebody offer me some help?

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hello, @jancbeck!

    This is a bit beyond my expertise as a first level support tech, so I'm going to flag the second level and see if they can offer some insight I'm unable to. Sometimes it can take a little while to get an answer from second level, they're very, very busy and have many responsibilities. I'll keep you posted on anything I hear.

    Thanks for contacting us!

  • jancbeck
    • New Recruit

    Thank you Michelle, I appreciate your reply.

    Just wanted to mention that I have chosen a subdirectory install and that I don't own a dedicated IP. However not having a dedicated IP didn't have any influence on the general working of the plugin up until I noticed that I'm not logged in when browsing a mapped domain.

  • Tyler Postle
    • CGO

    Hey Jancbeck,

    Hope you're doing well today!

    Have you tried using the "Cross-Domain autoogin" feature inside your Network Admin > Settings > Domain Mapping options?

    That should log you into all different domains on the network :slight_smile:

    Let us know if that does the trick for you.

    Have a great rest of your weekend!

    All the best,
    Tyler

    PS. I have attached a screenshot of the setting.

  • jancbeck
    • New Recruit

    Hello Tyler,

    thank you. Of course Cross-domain autologin was the first thing that came to my mind too. However after turning it on and signing in again, the problem persists.

    Meanwhile I tried replicating the issue on a local instance of Chassis with Multisites enabled and a custom domain mapped to the local WP installation.
    It turned out I could not replicate the problem on my local server. Everything worked as it should.

    So I then deactivated all plugins on the live server install but to no avail. There is not a lot left I could try to debug here since the install is quite new and has no fancy customizations (yet!).

    Next I want to try out running the plugin on a different install on the live server to find out if it has to do with the server environment or the specific WP install I'm running.

    There was something else that came to my mind though as a possible source for error: Could it be related to the fact that my install is running on an SSL encrypted domain however the domain I'm trying to map is not encrypted?

  • jancbeck
    • New Recruit

    Thanks for these threads, Michelle. Unfortunately none provided any help on how to setup SSL with Domain Mapping.

    Meanwhile I have tried to setup a second WP multisite install on the same server but this time with the original URL not being an SSL domain. It worked seamlessly.

    So as I see it my options are either...:
    1. Setup the multisite install in a non-SSL environment
    2. Purchase SSL certs for all mapped domains and use them for both frontend and admin.
    3. Accept the current situation and tell users they can't use their domains when they are logged in.

    2.) is not doable as I have a lot of amateur / non-profit users who can't afford SSL certs.
    3.) is a usability nightmare. I would be better off not using any domain mapping at all.
    1.) Is a bummer. It's 2014 and administration over SSL should be possible if not default.

  • Sam
    • The Incredible Code Injector

    Hi @jancbeck

    I tried to reproduce your issue with my original domain under ssl and multiple mapped domains without ssl and all seemed fine on my end. Is there anything that would help me reproduce the issue you're facing? Maybe event server spec/config will help with that.

    Thanks,
    Sam

    • jancbeck
      • New Recruit

      Can't think of anything special. Also tried to contact the host to find out if there is something special about how they handle SSL perhaps. I'm not even sure how to describe the issue since it's so closely related to WordPress and this plugin. I guess I just have to try out a few things and see if it helps.

  • Sam
    • The Incredible Code Injector

    Hi @jancbeck

    1) The maintenance plugin you are using acts before "Cross domain autologin" that's why it wouldn't work while the maintenance plugin is active

    2) Even when not in maintenance mode you would have redirect loop because you install is in a subfolder that's why i had to set define("COOKIEPATH", "/"); in your wp-config.php file to solve the issue.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.