The MU forums have moved to WordPress.org

Redirect issue when including 'wp-blog-header.php' (3 posts)

  1. somethingkindawierd
    Member
    Posted 18 years ago #

    I have an external script I am writing that needs access to users' posts databases. I have the entire script working with one issue:

    Every tip I find says to include the 'wp-blog-header.php' file for access to the worpdress API's. This does work, except for when the WPMU install is configured with the blogs at the end of the url, as in domain.com/blogname/ because when I include the header file my script gets redirected to a registration up page.

    So my question is, when the blog is set up to run as domain.com/blogname/ how can I include the necessary files to access the WPMU API's, namely the $wpdb object, without the app redirecting me to a new blog registration page?

  2. MrBrian
    Member
    Posted 18 years ago #

    Have you tried wp-load.php instead? Not sure why it's redirecting.. it's not supposed to. It goes to wp-signup.php right?

  3. leandroNavarro
    Member
    Posted 17 years ago #

    I think this is a bug in wpmu_settings.php (lin 115 approx)

    $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT *
    FROM $wpdb->blogs WHERE domain = %s",$domain) );

    fails, as $domain does not have correct info (at least in my install)

    if( constant( 'VHOST' ) == 'yes' ) {
            $current_blog = wp_cache_get( 'current_blog_' . $domain,
    'site-options' );
            if( !$current_blog ) {
                    $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT *
    FROM $wpdb->blogs WHERE domain = %s", $domain) );
                    if( !$current_blog ) //add this line and the following
                      $current_blog = $wpdb->get_row( wpdb->prepare("SELECT
    * FROM $wpdb->blogs WHERE domain = %s", $current_site->domain) ); //until here
                    if( $current_blog )
                            wp_cache_set( 'current_blog_' . $domain,
    $current_blog, 'site-options' );
            }

    $domain is unsuccessfully guessed at the beginning of the script. I use $current_site instead to retrieve $current_blog.

About this Topic

  • Started 18 years ago by somethingkindawierd
  • Latest reply from leandroNavarro