• Greg

    (@rebootnow)


    I have a subfolder install of WP multisite, let’s say at “domain.com”.

    I now need to load the WP environment in subdomains of domain.com, say “sub1.domain.com”, “sub2.domain.com”, … “subN.domain.com”. Note that these subdomains do not correspond to WP blogs. But I do need to have access to the logged in user, the database, etc.

    I have set up wildcard subdomains to load a php file that will display what I need for any particular subdomain, and I am including “wp-load.php” early in that file. The problem is that near line 99 in “ms-settings.php” it redirects to the main page of the site because $_SERVER[ ‘HTTP_HOST’ ] is the subdomain, not the main site domain.

    So how can I load the WP environment correctly in a non-blog subdomain?

    Do I need to somehow correctly set up the $current_site and $current_blog globals manually? Or is this something to do with the SUNRISE constant?

    I’m a bit lost, so any pointers would be much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Greg

    (@rebootnow)

    Updating…

    I have a prototype that works, but I’m worried about the side effects of what I’m doing so it would be great if someone who’s familiar with the core could weigh in.

    What I am doing is pre-populating the $current_site and $current_blog globals appropriately before including “wp-load”. Then, “ms-settings” doesn’t try to create these and doesn’t hit the code path that detects the subdomain and redirects to the front page.

    I can now access member information (e.g. using ‘get_userdata’) and $wpdb.

    Does this seem like a reasonable approach?

    Thread Starter Greg

    (@rebootnow)

    I guess this party has moved to StackExchange.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Loading the WP environment in a (non-blog) subdomain’ is closed to new replies.