From 34c46c0eac3362bbf8b1e1b7c90b6e4a3a5d1d79 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Fri, 22 Jan 2010 23:51:23 +0000 Subject: [PATCH] Change get_blogs_of_user to include 3.0 main site, Fixes #11975 git-svn-id: https://develop.svn.wordpress.org/trunk@12807 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/ms-functions.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 877d8b1566..608623dbdf 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -469,15 +469,19 @@ function get_blogs_of_user( $id, $all = false ) { $blogs = $match = array(); foreach ( (array) $user as $key => $value ) { - if ( false !== strpos( $key, '_capabilities') && 0 === strpos( $key, $wpdb->base_prefix ) && preg_match( '/' . $wpdb->base_prefix . '(\d+)_capabilities/', $key, $match ) ) { - $blog = get_blog_details( $match[1] ); + if ( false !== strpos( $key, '_capabilities') && 0 === strpos( $key, $wpdb->base_prefix ) && preg_match( '/' . $wpdb->base_prefix . '((\d+)_)?capabilities/', $key, $match ) ) { + if ( count( $match ) > 2 ) + $blog_id = $match[ 2 ]; + else + $blog_id = 1; + $blog = get_blog_details( $blog_id ); if ( $blog && isset( $blog->domain ) && ( $all == true || $all == false && ( $blog->archived == 0 && $blog->spam == 0 && $blog->deleted == 0 ) ) ) { - $blogs[$match[1]]->userblog_id = $match[1]; - $blogs[$match[1]]->blogname = $blog->blogname; - $blogs[$match[1]]->domain = $blog->domain; - $blogs[$match[1]]->path = $blog->path; - $blogs[$match[1]]->site_id = $blog->site_id; - $blogs[$match[1]]->siteurl = $blog->siteurl; + $blogs[ $blog_id ]->userblog_id = $blog_id; + $blogs[ $blog_id ]->blogname = $blog->blogname; + $blogs[ $blog_id ]->domain = $blog->domain; + $blogs[ $blog_id ]->path = $blog->path; + $blogs[ $blog_id ]->site_id = $blog->site_id; + $blogs[ $blog_id ]->siteurl = $blog->siteurl; } } }