Domain Mapping login issue

I'm mapping domains in my multisite, i.e. Domain mapping, but without a plugin. The mapping seems to be working fine, but when I log in through the mapped domain, it still shows I'm not logged in through the original subsite URL. I guess it is supposed to sync, but seems to be not working. I just want to be able to log in through the mapped domain not both the mapped domain and original subsite URL at the same time. I tried putting the following in the wp-config.php file, but it didn't seem to work:

https://pastebin.com/gZkv1ACi  Any advices are appreciated.

  • Ash
    • WordPress Hacker

    Hello Simplebutcreative Media

    Please try the following code:

    add_action( 'muplugins_loaded', function(){
    	global $current_blog, $current_site;
    	if ( false === stripos( $current_blog->domain, $current_site->cookie_domain ) ) {
    		$current_site->cookie_domain = $current_blog->domain;
    	}
    });

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Let us know if that works for you. Have a nice day!

    Cheers,
    Ash

  • Simplebutcreative Media
    • Site Builder, Child of Zeus

    Hey Ash

    Thanks for the quick reply!

    Ok I added the code through the MU Plugins way. Seems like I'm still getting the same issues.

    I log in through the mapped domain wp-admin...No issues there.

    While logged in, I type in the original subsite URL -

    https://network.simplebutcreative.com/empoweryourlyfe

    On this page, it shows that I'm not logged in.

    The idea is that when someone types the original subsite URL it should redirect to the mapped domain correct? I just want to make that it suppose to be like that..

    While logged in through the mapped domain, every time I go to Pro Site default checkout page it doesn't show that I'm logged in. It wants me to log in again through the Pro Site checkout page.

    I would really like to keep the plugin count very low but I might just have to re-install domain mapping again...

  • Simplebutcreative Media
    • Site Builder, Child of Zeus

    Ash

    I was reading this tutorial earlier today, pacific time.

    https://wparena.com/custom-domain-mapping-wordpress-multisite-network/#customdomainwithoutplugin

    Checkout the last part of this guide...You think this can work?

    Change this

    define( ‘DOMAIN_CURRENT_SITE’, ‘domain name.com’ );

    into

    define( ‘DOMAIN_CURRENT_SITE’, “. $_SERVER[‘HTTP_HOST’].” );

    The code on top looks like part of the multisite setup...nvm yes it is!

    I also added this snippet into my wp-config. This one is from Wordpress Codex for the native domain mapping.

    define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);

    A lot of guides out there says to add that code into wp-config but it seems to be not working for me.

    • Ash
      • WordPress Hacker

      If the above defines do not solve the issue, then, unfortunately, we are out of ideas :slight_frown: James and me were trying to find a solution and we found the above defines worked for James.

      Yes, maybe you can give another try our domain mapping plugin. Let's see what happens then :slight_smile:

      Please keep us updated. Have a nice day!

      Cheers,
      Ash

  • Simplebutcreative Media
    • Site Builder, Child of Zeus

    Ash

    Thanks for the help! I'm sure the dm plugin will work better. I was just trying to cut down the plugin install for this particular multisite installation. This particular project is just an easy way for me to manage my customer's websites.

    But I'm having all kinds of issues...I might also need to upgrade to siteground's cloud hosting but I'm no quite ready to upgrade to that plan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.