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.
define('WP_USE_THEMES', false);
define( 'DOMAIN_CURRENT_SITE', $siteRow['domain'] );
define( 'PATH_CURRENT_SITE', "https://wordpress.stackexchange.com/" );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', $siteRow['wp_blog_id'] );
$_SERVER = array(
"HTTP_HOST" => $siteRow['domain'],
"SERVER_NAME" => $siteRow['domain'],
"REQUEST_URI" => "https://wordpress.stackexchange.com/",
"REQUEST_METHOD" => "GET"
);
require_once WP_PATH.'wp-load.php';
switch_to_blog($siteRow['wp_blog_id']);
$siteRow contains details about the target site. Note: This cannot be inside a function due to global variable restraints.
Related Posts:
- Create mobile site with same content just different theme
- How to hide or remove unwanted widgets on Multisite installation?
- How can I diagnose a slow WordPress admin?
- How to enable a site administrator to edit users in a WordPress network/ multisite setup?
- WP-Admin not working properly at WordPress multisite with subdirectories
- Multisite posts in categories on network
- find a random blogid across my multisite network that has at least one post published
- Security in WordPress plugin development
- Hide a theme on list of themes in wp-admin without editing core files
- Difference Between Admin and Super Admin in Database
- wp-admin slow in multisite
- WPDB Multiple site’s posts and get featured images
- Don’t allow access to wp-admin but allow admin-ajax requests to be fulfilled on frontend?
- Timeout While Upgrading Network in Multi-site
- Uploading Images to Multi-Site Causes Failure to HTTP Error
- Multisite wp-admin redirect loop
- WordPress network (multisite) /wp-admin/ redirect loop (ERR_TOO_MANY_REDIRECTS)
- Copy posts from one blog to another in multisite environment
- My subsites accidentally went from one multisite network to another. How do I change it back?
- Redirect loop (only for multisite network admin)
- Manipulate list of themes in wp-admin
- Subsites in Multisite installation throwing 404 error on wp-admin in IIS 7
- How to remove Broken Link Checker widget from admin menu
- Using $wpdb Class to Pull Recent Comments Across a Network
- How to set Active plugins as the default screen?
- Why can’t I delete original user in multisite? Options for manual removal
- Multisite network admin – URL / redirect error
- How to order by blog ID in this multisite ‘List Blogs’ custom function
- Cookie nonce is invalid – Multisite
- WordPress mutisite migration
- Why does the My Site dropdown show only a single domain?
- Bootstrapping WordPress MultiSite Outsite of WordPress – No $wpdb
- Super admin access to a forgotten WP instance?
- Multi-site: removing /blog from posts
- Retrieving multisite blog IDs, somehow failing to foreach them properly
- Network Plugin Creating Pages for Different Subdomains
- Iframe being removed only for some users when publishing a page
- Optimizing Query used for a Shortcode
- WP Multisite with Domain Mapping : Preventing User Access to Dashboard
- Use WordPress MultiSite (WPMS) with a remote database for each created site
- 2 website 1 database… Local to online
- Moving wp-admin folder to a different host in a multisite environment
- How to display users with posts published between two dates (Sorted by Post-Count) [Multisite]
- Site’s admin created with wpmu_create_blog accessible only on 2nd attempt
- Is There A Plugin to Create WP Multisite Installs programatically
- Can’t log in to wp-admin after setting up Multisite
- Check if current site ID and value exist in WPDB
- Multi-site site nav, wpdb->prepare missing argument
- WP MS: How to query over the network
- Infamous admin login redirect
- WordPress multisite second site admin resulting in too many redirects error
- Multisite wp-admin redirecting to main wp-admin using NGINX
- WordPress Multisite: Login to all subsites at once
- How to Add Super Admin for WordPress multi-site
- network admin pages not linked to correctly
- Multisite – cannot remove specific sub-menu its parent menu. All sub-menus disappear
- How to have same admin login for more than one site?
- WP Admin Panel for Multi-site install not loading JavaScript for one Subdomain
- Backend freezing on certain pages of a subsite
- WP DB Location for “Next Post to Create” Index Value
- Admin user getting redirected to /wp-admin/user
- Pages redirect me to the homepage
- Run “get_the_post_thumbnail” with a different table prefix?
- Many big issues in the website, WP_Debug not showing
- What could be changing my WP password and blocking plugins from installing?
- Setting up a wordpress network with third level domains
- Troubleshooting a “You do not have sufficient permissions to access this page” error
- WordPress 3 Multisite using subdomains.- DNS on Cpanel question
- Remove Site Name from register form – Multisite
- Set up collaborative site
- Add role across network in multisite
- NGINX Multisite Rewrite rules
- Categories box not showing on post edit pages
- On Multisite: Loop to Show First Four Images of Recent Posts Across Network
- how to enable different number of revisions for different blogs when using WPMU?
- “Preview Changes” button doesn’t show changes for previously published posts/pages
- How to get the site administrator/s by blog id
- Retrieve taxonomies from arbitrary site
- Child Site doesn’t appear in the Network menu
- Multisite installation not in root – how to make live?
- Can’t view network plugins.php or upgrade-core.php on multisite
- Can I use WP to create a multisite importing the posts of 3 old WP website?
- Merge Multisites with Shared Network Media Library
- Contact Form 7 in Multisite [closed]
- Change post-slug using wordpress API? Change permalink of a post using php / jquery?
- Cannot select signup_meta upon multisite user activation
- $wpdb->update prefixes database name to table when executing query
- Redirect Plugins.php to New Plugin Page
- Multisite sites output on a single page
- multisite – unable to connect to network administration
- WordPress multisite redirect one custom non www domain to www
- How to resolve a reload loop issue in the frontend when logged in to WordPress multi-site backend admin area
- Max number of sub folders
- Multisite: Run a subdomain install from a directory install
- Plugin data shared in Multisite
- Remove blog slug from WPMU?
- WordPress multisite and one database
- Planning on Multisite Before Creating A Network
- Creating a new Sortable Column in WordPress Admin
- Redirect to Multisite site 2 if site 1 has a setting