Don't mangle the primary_blog option when trying to fix it. Don't set people to be a subscriber on a blog they already have a role for. See #15316

git-svn-id: https://develop.svn.wordpress.org/trunk@16179 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood
2010-11-04 09:31:58 +00:00
parent 3c5457259b
commit 75dc7c8c37

View File

@@ -79,17 +79,17 @@ function get_active_blog_for_user( $user_id ) {
$primary_blog = get_user_meta( $user_id, 'primary_blog', true );
$first_blog = current($blogs);
if ( $primary_blog ) {
if ( false !== $primary_blog ) {
if ( ! isset( $blogs[ $primary_blog ] ) ) {
add_user_to_blog( $first_blog->blog_id, $user_id, 'subscriber' );
update_user_meta( $user_id, 'primary_blog', $first_blog->blog_id );
update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
$primary = $first_blog;
} else {
$primary = get_blog_details( $primary_blog );
}
} else {
add_user_to_blog( $first_blog->blog_id, $user_id, 'subscriber' );
update_user_meta( $user_id, 'primary_blog', $first_blog->blog_id );
//TODO Review this call to add_user_to_blog too - to get here the user must have a role on this blog?
add_user_to_blog( $first_blog->userblog_id, $user_id, 'subscriber' );
update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
$primary = $first_blog;
}