I am merging WordPress into a existing system and require our users to be able to make posts to a multi-site WP install. I have a database table that will link our own member to specific blog IDs and stuff, so there will be no need for user/logins as far as WP is concerned.
What I really need to know is how to run certain WP functions outside of WP itself – on a completely different domain infact (but same server). I have tried simply including wp-load.php in our existing admin panel but as soon as I do it redirects to the main site – I assume because the domains do not match:
domain1.com and domain2.com are both on the same server, domain1.com is the WP MU setup, on domain2.com in our own admin area I am including wp-load.php and as soon as I do it redirects me straight to the homepage of domain1.com.
Is it even preferable to do it this way? I have seen a few examples where people have directly queried the WP database to insert posts. but if that’s the case I have to ask myself why I am even using WP for this project at all?! I am thinking about using WP XMLRPC API but I need more power than that and don’t wish to turn in on really.
Ok I have cracked it, by spoofing the $_SERVER variable and pre-defing some constants, I was able to prevent WordPress from redirecting after the inclusion of wp-load.php.
$siteRow contains details about the target site. Note: This cannot be inside a function due to global variable restraints.
Hi
I am a hacker not a programmer and I was able to get this to work quickly, but I think I was lucky.
I assumed the “define” commands were what was in my multisite dashboard and I added the $_server code to the top of my wp_insert_post script and it worked.
I didn’t use the following:
I used the following to select the blog although as it was the default blog maybe that wasn’t necessary:
Or should I have put the “define” statements into the script?
Cheers
Jack