Today I learned the hard way that WordPress multisite doesn’t quite support domain mapping out of the box the way I expect it to.
I’m working on a website-as-a-service product called ToothPress (more on that at some point in the future). On a paid plan, ToothPress customers will be able to map their custom domain. My dad is my first beta user, so I changed his domain from milwaukiefamilydentistry.toothpress.com to milwaukiefamilydentistry.com:
Then, I went to log into his dashboard:
Uh oh, what’s going on?!
As it turns out, WordPress doesn’t magically handle setting the correct COOKIE_DOMAIN. You’ll need to take care of this yourself:
Et voila!
6 Comments
This seems like the same thing as defining the COOKIE_DOMAIN constant in `wp-config`, no?
`define(‘COOKIE_DOMAIN’, $_SERVER[‘HTTP_HOST’]);`
Not quite. In the example you’ve provided, the cookie domain would be dynamic for subdomains of the primary network domain, which isn’t what I want.
Got it.
Where do you add this? In the functions.php file?
It would need to be loaded much earlier than that, in an mu plugin.
I can’t thank you enough for this fix. I spent hours trying to fix my secondary site once it was mapped to a domain and nothing worked . . . until this. I really appreciate it.