Changeset 15746 for trunk/wp-includes/ms-functions.php
- Timestamp:
- 10/07/2010 07:34:18 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/ms-functions.php
r15678 r15746 60 60 * @since MU 1.0 61 61 * @uses get_blogs_of_user() 62 * @uses get_dashboard_blog()63 62 * @uses add_user_to_blog() 64 63 * @uses update_user_meta() … … 73 72 global $wpdb; 74 73 $blogs = get_blogs_of_user( $user_id ); 75 if ( empty( $blogs ) ) { 76 $details = get_dashboard_blog(); 77 add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); 78 update_user_meta( $user_id, 'primary_blog', $details->blog_id ); 79 wp_cache_delete( $user_id, 'users' ); 80 return $details; 81 } 74 if ( empty( $blogs ) ) 75 return null; 76 77 if ( !is_multisite() ) 78 return $blogs[$wpdb->blogid]; 82 79 83 80 $primary_blog = get_user_meta( $user_id, 'primary_blog', true ); 84 $ details = get_dashboard_blog();81 $first_blog = current($blogs); 85 82 if ( $primary_blog ) { 86 if ( isset( $blogs[ $primary_blog ] ) == false) {87 add_user_to_blog( $ details->blog_id, $user_id, 'subscriber' );88 update_user_meta( $user_id, 'primary_blog', $ details->blog_id );89 wp_cache_delete( $user_id, 'users' );83 if ( ! isset( $blogs[ $primary_blog ] ) ) { 84 add_user_to_blog( $first_blog->blog_id, $user_id, 'subscriber' ); 85 update_user_meta( $user_id, 'primary_blog', $first_blog->blog_id ); 86 $primary = $first_blog; 90 87 } else { 91 $ details= get_blog_details( $primary_blog );88 $primary = get_blog_details( $primary_blog ); 92 89 } 93 90 } else { 94 add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog 95 update_user_meta( $user_id, 'primary_blog', $details->blog_id ); 96 } 97 98 if ( ( is_object( $details ) == false ) || ( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) ) { 91 add_user_to_blog( $first_blog->blog_id, $user_id, 'subscriber' ); 92 update_user_meta( $user_id, 'primary_blog', $first_blog->blog_id ); 93 $primary = $first_blog; 94 } 95 96 if ( ( ! is_object( $primary ) ) || ( is_object( $primary ) && $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) { 99 97 $blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs. 100 98 $ret = false; … … 106 104 if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) { 107 105 $ret = $blog; 108 $changed = false; 109 if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id ) { 106 if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id ) 110 107 update_user_meta( $user_id, 'primary_blog', $blog_id ); 111 $changed = true; 112 } 113 if ( !get_user_meta($user_id , 'source_domain', true) ) { 108 if ( !get_user_meta($user_id , 'source_domain', true) ) 114 109 update_user_meta( $user_id, 'source_domain', $blog->domain ); 115 $changed = true;116 }117 if ( $changed )118 wp_cache_delete( $user_id, 'users' );119 110 break; 120 111 } 121 112 } 122 113 } else { 123 // Should never get here 124 $dashboard_blog = get_dashboard_blog(); 125 add_user_to_blog( $dashboard_blog->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog 126 update_user_meta( $user_id, 'primary_blog', $dashboard_blog->blog_id ); 127 return $dashboard_blog; 114 return null; 128 115 } 129 116 return $ret; 130 117 } else { 131 return $ details;118 return $primary; 132 119 } 133 120 } … … 841 828 842 829 wpmu_welcome_user_notification($user_id, $password, $meta); 843 $user_site = get_site_option( 'dashboard_blog', $current_site->blog_id );844 845 if ( $user_site == false )846 add_user_to_blog( '1', $user_id, get_site_option( 'default_user_role', 'subscriber' ) );847 else848 add_user_to_blog( $user_site, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );849 830 850 831 add_new_user_to_blog( $user_id, $user_email, $meta ); … … 927 908 update_option( 'blog_public', (int)$meta['public'] ); 928 909 929 if ( !is_super_admin() && get_user_meta( $user_id, 'primary_blog', true ) == get_site_option( 'dashboard_blog', 1) )910 if ( !is_super_admin() && ! get_user_meta( $user_id, 'primary_blog', true ) ) 930 911 update_user_meta( $user_id, 'primary_blog', $blog_id ); 931 912 … … 1461 1442 add_action('update_option_blog_public', 'update_blog_public', 10, 2); 1462 1443 1463 /* Redirect all hits to "dashboard" blog to wp-admin/ Dashboard. */1464 function redirect_mu_dashboard() {1465 global $current_site, $current_blog;1466 1467 $dashboard_blog = get_dashboard_blog();1468 if ( $current_blog->blog_id == $dashboard_blog->blog_id && $dashboard_blog->blog_id != $current_site->blog_id ) {1469 $protocol = ( is_ssl() ? 'https://' : 'http://' );1470 wp_redirect( $protocol . $dashboard_blog->domain . trailingslashit( $dashboard_blog->path ) . 'wp-admin/' );1471 die();1472 }1473 }1474 add_action( 'template_redirect', 'redirect_mu_dashboard' );1475 1476 1444 function get_dashboard_blog() { 1477 1445 if ( $blog = get_site_option( 'dashboard_blog' ) )
Note: See TracChangeset
for help on using the changeset viewer.