Changeset 1120
- Timestamp:
- 10/22/07 17:16:22 (1 year ago)
- Files:
-
- trunk/wp-admin/menu.php (modified) (1 diff)
- trunk/wp-admin/wpmu-edit.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-admin/menu.php
r1069 r1120 151 151 uksort($menu, "strnatcasecmp"); // make it all pretty 152 152 153 if (! user_can_access_admin_page()) { 154 global $wpdb; 153 if ( !user_can_access_admin_page() ) { 155 154 // find the blog of this user first 156 $primary_blog = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '$user_ID' AND meta_key = 'primary_blog'" ); 157 if( $primary_blog ) { 155 $primary_blog = (int) get_usermeta( $user_ID, 'primary_blog' ); 156 if( $primary_blog != 0 ) { 157 global $wpdb; 158 158 $newblog = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$primary_blog}'" ); 159 159 if( $newblog != null ) { 160 header( "Location: http://" . $newblog->domain . $newblog->path . "wp-admin/" ); 161 exit; 160 $blogs = get_blogs_of_user( $user_ID ); 161 if ( empty($blogs) || $blogs == false ) { // If user haven't any blog 162 update_usermeta( $user_ID, 'wp_1_capabilities', array('subscriber' => true)); // Add subscriber permission for first blog. 163 wp_redirect( 'http://'.$current_site->domain . $current_site->path. 'wp-admin/' ); 164 exit(); 165 } 166 167 foreach ( (array) $blogs as $blog ) { 168 if ( $blog->userblog_id == $newblog->blog_id ) { 169 wp_redirect( 'http://'.$newblog->domain . $newblog->path . 'wp-admin/' ); 170 exit(); 171 } 172 } 173 174 $blog = $blogs[0]; // Take the first blog... 175 wp_redirect( 'http://'.$blog->domain . $blog->path. 'wp-admin/' ); 176 exit(); 162 177 } 163 178 } trunk/wp-admin/wpmu-edit.php
r1110 r1120 187 187 reset( $_POST['blogusers'] ); 188 188 foreach ( (array) $_POST['blogusers'] as $key => $val ) { 189 $wpdb->query( "DELETE FROM " . $wpdb->usermeta . " WHERE meta_key = '" . $wpmuBaseTablePrefix . $id . "_capabilities' AND user_id = '" . $key . "'" ); 189 delete_usermeta( $key, $wpmuBaseTablePrefix.$id.'_capabilities' ); 190 delete_usermeta( $key, $wpmuBaseTablePrefix.$id.'_user_level' ); 191 delete_usermeta( $key, 'primary_blog', $id ); // Delete primary blog if need. 190 192 } 191 193 } … … 403 405 if( is_array( $_POST['user'] ) == true ) { 404 406 $user = $_POST['user']; 405 if ( empty($user['username']) ||empty($user['email']) ) {407 if ( empty($user['username']) && empty($user['email']) ) { 406 408 wp_die( __("<p>Missing username and email.</p>") ); 407 } 409 } elseif ( empty($user['username']) ) { 410 wp_die( __("<p>Missing username.</p>") ); 411 } elseif ( empty($user['email']) ) { 412 wp_die( __("<p>Missing email.</p>") ); 413 } 414 408 415 $password = generate_random_password(); 409 416 $user_id = wpmu_create_user(wp_specialchars( strtolower( $user['username'] ) ), $password, wp_specialchars( $user['email'] ) );
