Get WordPress Domain Mapped URL

On PrimaryBlogger we have a custom “Your Account” popup with a quick overview of all of the users blogs, including information about pending comments and links to the admin area and site. It’s pretty good, go have a look at it in action.

I did have one problem though, if you are using the WordPress MU Domain Mapping plugin, or variation thereof, then you may have trouble pulling in the mapped domain to create your links. I’m using the get_blogs_of_user function using the user’s ID, but you will notice that there are only certain things you can pull with this information, mainly the siteid and siteurl. I thought the siteurl would serve me well, but it appears that it sends the original domain as it polls the site’s options table. Domain mapping never changes the site’s options to reflect the change, it has it’s own table that it references.

So, where do we go from here? I had a look through the domain-mapping.php and found the domain_mapping_siteurl function. It looked perfect, so I went ahead and modified it to run with a custom siteid instead of the current blog’s ID. Check out the Gist below for the code, explanation and example.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php