I have come across a small problem in WordPress multisite. When using a mapping to a custom domain, the domain is apparently mapped but internally the site retains your main domain with a sub-domain as its address. So, while externally it may be “example.com”, internally it is still “example.mysite.net”. Usually, this does not cause any trouble but you may run into unexpected problems with more advanced stuff and some plugins may function incorrectly.
I came across this when trying to configure Facebook with Social Networks Auto-Poster (SNAP) plugin. The plugin will issue an OAuth request to Facebook but the request fails because the plugin uses the “example.mysite.net” instead of “example.com” as you would expect. So Facebook understandably rejects the request to authorize. And this same thing may happen in other places.
The site URL comes from the database, options “siteurl” and “home”. Fire up your favorite SQL tool and head for the database. Find your table wp_XX_options where the site in question is stored (XX being the id of the site, they simply get numbered from 1 up). Change the two options to the correct URLs and things should start looking up.
Remember to change the URLs back to “example.mysite.net” when you remove the domain mapping.… -->
The WordPress multisite install is a great thing. Except when you come across something that works not the way you expect.
So, the WordPress multisite installed on example.com with blogs on subdomain basis will give you sites with names like great.example.com and aruberusan.example.com. Of course, we all like nice looking domain names, so you install a mapping plugin and get the domain aruberusan.com map to your aruberusan.example.com and it all just works… So now you happily access your blog at aruberusan.com. Great. Until you run into trouble because internally your blog’s site address is still aruberusan.example.com. And the calls to get_site_url(), home_url(), admin_url() and so on still return you the old original name of your site before mapping, in my case the aruberusan.example.com.
This sucks and I could not find a solution to this weird problem. The only thing that came to mind was to use the actual site URL from the request and recompose the URL manually like this:
I would not call it a beautiful solution or even a proper one but it works. It is amazing that you cannot get the right URL from anywhere. Oh, and why you need it? Well, if you are going to post to, let’s say, Facebook, for example, with something like the SNAP plugin, you better have the right URL for your site or else…… -->