3 * Action handler for Multisite administration panels.
6 * @subpackage Multisite
10 require_once( './admin.php' );
12 if ( ! is_multisite() )
13 wp_die( __( 'Multisite support is not enabled.' ) );
15 if ( empty( $_GET['action'] ) )
16 wp_redirect( admin_url( 'ms-admin.php' ) );
18 do_action( 'wpmuadminedit' , '');
20 if ( isset( $_GET['id' ]) )
21 $id = intval( $_GET['id'] );
22 elseif ( isset( $_POST['id'] ) )
23 $id = intval( $_POST['id'] );
25 switch ( $_GET['action'] ) {
27 check_admin_referer( 'siteoptions' );
28 if ( ! current_user_can( 'manage_network_options' ) )
29 wp_die( __( 'You do not have permission to access this page.' ) );
31 if ( empty( $_POST ) )
32 wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">options page</a>.', esc_url( admin_url( 'ms-options.php' ) ) ) ) );
34 if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array( $_POST['WPLANG'], get_available_languages() ) ) )
35 update_site_option( 'WPLANG', $_POST['WPLANG'] );
37 if ( is_email( $_POST['admin_email'] ) )
38 update_site_option( 'admin_email', $_POST['admin_email'] );
40 $illegal_names = split( ' ', $_POST['illegal_names'] );
41 foreach ( (array) $illegal_names as $name ) {
42 $name = trim( $name );
44 $names[] = trim( $name );
46 update_site_option( 'illegal_names', $names );
48 if ( $_POST['limited_email_domains'] != '' ) {
49 $limited_email_domains = str_replace( ' ', "\n", $_POST['limited_email_domains'] );
50 $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) );
51 $limited_email = array();
52 foreach ( (array) $limited_email_domains as $domain ) {
53 $domain = trim( $domain );
54 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
55 $limited_email[] = trim( $domain );
57 update_site_option( 'limited_email_domains', $limited_email );
59 update_site_option( 'limited_email_domains', '' );
62 if ( $_POST['banned_email_domains'] != '' ) {
63 $banned_email_domains = split( "\n", stripslashes( $_POST['banned_email_domains'] ) );
65 foreach ( (array) $banned_email_domains as $domain ) {
66 $domain = trim( $domain );
67 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
68 $banned[] = trim( $domain );
70 update_site_option( 'banned_email_domains', $banned );
72 update_site_option( 'banned_email_domains', '' );
74 update_site_option( 'default_user_role', $_POST['default_user_role'] );
75 if ( trim( $_POST['dashboard_blog_orig'] ) == '' )
76 $_POST['dashboard_blog_orig'] = $current_site->blog_id;
77 if ( trim( $_POST['dashboard_blog'] ) == '' ) {
78 $_POST['dashboard_blog'] = $current_site->blog_id;
79 $dashboard_blog_id = $current_site->blog_id;
80 } elseif ( ! preg_match( '/(--|\.)/', $_POST['dashboard_blog'] ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $_POST['dashboard_blog'] ) ) {
81 $dashboard_blog = $_POST['dashboard_blog'];
82 $blog_details = get_blog_details( $dashboard_blog );
83 if ( false === $blog_details ) {
84 if ( is_numeric( $dashboard_blog ) )
85 wp_die( __( 'A dashboard site referenced by ID must already exist' ) );
86 if ( is_subdomain_install() ) {
87 $domain = $dashboard_blog . '.' . $current_site->domain;
88 $path = $current_site->path;
90 $domain = $current_site->domain;
91 $path = trailingslashit( $current_site->path . $dashboard_blog );
94 $dashboard_blog_id = wpmu_create_blog( $domain, $path, __( 'My Dashboard' ), $current_user->id , array( 'public' => 0 ), $current_site->id );
97 $dashboard_blog_id = $blog_details->blog_id;
100 if ( is_wp_error( $dashboard_blog_id ) )
101 wp_die( __( 'Problem creating dashboard site: ' ) . $dashboard_blog_id->get_error_message() );
102 if ( $_POST['dashboard_blog_orig'] != $_POST['dashboard_blog'] ) {
103 $users = get_users_of_blog( get_site_option( 'dashboard_blog' ) );
104 $move_users = array();
105 foreach ( (array)$users as $user ) {
106 $user_meta_value = unserialize( $user->meta_value );
107 if ( is_array( $user_meta_value ) && array_pop( array_keys( $user_meta_value ) ) == 'subscriber' )
108 $move_users[] = $user->user_id;
110 if ( false == empty( $move_users ) ) {
111 foreach ( (array)$move_users as $user_id ) {
112 remove_user_from_blog($user_id, get_site_option( 'dashboard_blog' ) );
113 add_user_to_blog( $dashboard_blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
114 update_user_meta( $user_id, 'primary_blog', $dashboard_blog_id );
118 update_site_option( 'dashboard_blog', $dashboard_blog_id );
120 $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'admin_notice_feed', 'global_terms_enabled' );
121 $checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1 );
122 foreach ( $checked_options as $option_name => $option_unchecked_value ) {
123 if ( ! isset( $_POST[$option_name] ) )
124 $_POST[$option_name] = $option_unchecked_value;
126 foreach ( $options as $option_name ) {
127 if ( ! isset($_POST[$option_name]) )
129 $value = stripslashes_deep( $_POST[$option_name] );
130 update_site_option( $option_name, $value );
133 // Update more options here
134 do_action( 'update_wpmu_options' );
136 wp_redirect( add_query_arg( 'updated', 'true', admin_url( 'ms-options.php' ) ) );
140 check_admin_referer( 'add-blog', '_wpnonce_add-blog' );
142 if ( ! current_user_can( 'manage_sites' ) )
143 wp_die( __( 'You do not have permission to access this page.' ) );
145 if ( is_array( $_POST['blog'] ) == false )
146 wp_die( __( 'Can’t create an empty site.' ) );
147 $blog = $_POST['blog'];
149 if ( ! preg_match( '/(--)/', $blog['domain'] ) && preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) )
150 $domain = strtolower( $blog['domain'] );
152 // If not a subdomain install, make sure the domain isn't a reserved word
153 if ( ! is_subdomain_install() ) {
154 $subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) );
155 if ( in_array( $domain, $subdirectory_reserved_names ) )
156 wp_die( sprintf( __('The following words are reserved for use by WordPress functions and cannot be used as blog names: <code>%s</code>' ), implode( '</code>, <code>', $subdirectory_reserved_names ) ) );
159 $email = sanitize_email( $blog['email'] );
160 $title = $blog['title'];
162 if ( empty( $domain ) )
163 wp_die( __( 'Missing or invalid site address.' ) );
164 if ( empty( $email ) )
165 wp_die( __( 'Missing email address.' ) );
166 if ( !is_email( $email ) )
167 wp_die( __( 'Invalid email address.' ) );
169 if ( is_subdomain_install() ) {
170 $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain );
173 $newdomain = $current_site->domain;
174 $path = $base . $domain . '/';
178 $user_id = email_exists($email);
179 if ( !$user_id ) { // Create a new user with a random password
180 $password = wp_generate_password();
181 $user_id = wpmu_create_user( $domain, $password, $email );
182 if ( false == $user_id )
183 wp_die( __( 'There was an error creating the user.' ) );
185 wp_new_user_notification( $user_id, $password );
188 $wpdb->hide_errors();
189 $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id );
190 $wpdb->show_errors();
191 if ( !is_wp_error( $id ) ) {
192 $dashboard_blog = get_dashboard_blog();
193 if ( !is_super_admin( $user_id ) && get_user_option( 'primary_blog', $user_id ) == $dashboard_blog->blog_id )
194 update_user_option( $user_id, 'primary_blog', $id, true );
195 $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) );
196 wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
197 wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) );
198 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add-blog' ), wp_get_referer() ) );
201 wp_die( $id->get_error_message() );
206 check_admin_referer( 'editblog' );
207 if ( ! current_user_can( 'manage_sites' ) )
208 wp_die( __( 'You do not have permission to access this page.' ) );
210 if ( empty( $_POST ) )
211 wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">sites page</a>', esc_url( admin_url( 'ms-sites.php' ) ) ) ) );
213 switch_to_blog( $id );
216 $allowedthemes = array();
217 if ( isset($_POST['theme']) && is_array( $_POST['theme'] ) ) {
218 foreach ( $_POST['theme'] as $theme => $val ) {
220 $allowedthemes[$theme] = true;
223 update_option( 'allowedthemes', $allowedthemes );
226 if ( is_array( $_POST['option'] ) ) {
228 $count = count( $_POST['option'] );
229 foreach ( (array) $_POST['option'] as $key => $val ) {
230 if ( $key === 0 || is_array( $val ) )
231 continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
233 update_option( $key, stripslashes( $val ) );
235 update_option( $key, stripslashes( $val ), false ); // no need to refresh blog details yet
241 if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) {
242 $blog_address = get_blogaddress_by_domain( $_POST['blog']['domain'], $_POST['blog']['path'] );
243 if ( get_option( 'siteurl' ) != $blog_address )
244 update_option( 'siteurl', $blog_address );
246 if ( get_option( 'home' ) != $blog_address )
247 update_option( 'home', $blog_address );
250 // rewrite rules can't be flushed during switch to blog
251 delete_option( 'rewrite_rules' );
253 // update blogs table
254 $blog_data = stripslashes_deep( $_POST['blog'] );
255 update_blog_details( $id, $blog_data );
258 $blog_prefix = $wpdb->get_blog_prefix( $id );
261 if ( isset( $_POST['role'] ) && is_array( $_POST['role'] ) == true ) {
262 $newroles = $_POST['role'];
265 foreach ( (array) $newroles as $userid => $role ) {
266 $user = new WP_User( $userid );
269 $user->for_blog( $id );
270 $user->set_role( $role );
275 if ( isset( $_POST['blogusers'] ) && is_array( $_POST['blogusers'] ) ) {
276 reset( $_POST['blogusers'] );
277 foreach ( (array) $_POST['blogusers'] as $key => $val )
278 remove_user_from_blog( $key, $id );
282 if ( isset( $_POST['user_password'] ) && is_array( $_POST['user_password'] ) ) {
283 reset( $_POST['user_password'] );
284 $newroles = $_POST['role'];
285 foreach ( (array) $_POST['user_password'] as $userid => $pass ) {
286 unset( $_POST['role'] );
287 $_POST['role'] = $newroles[ $userid ];
289 $cap = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '{$userid}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" );
290 $userdata = get_userdata($userid);
291 $_POST['pass1'] = $_POST['pass2'] = $pass;
292 $_POST['email'] = $userdata->user_email;
293 $_POST['rich_editing'] = $userdata->rich_editing;
294 edit_user( $userid );
296 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id = '{$userid}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" );
299 unset( $_POST['role'] );
300 $_POST['role'] = $newroles;
304 if ( !empty( $_POST['newuser'] ) ) {
305 $newuser = $_POST['newuser'];
306 $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) );
308 $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" );
309 if ( $user == false )
310 add_user_to_blog( $id, $userid, $_POST['new_role'] );
313 do_action( 'wpmu_update_blog_options' );
314 restore_current_blog();
315 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'editblog', 'id' => $id ), wp_get_referer() ) );
319 check_admin_referer('deleteblog');
320 if ( ! current_user_can( 'manage_sites' ) )
321 wp_die( __( 'You do not have permission to access this page.' ) );
323 if ( $id != '0' && $id != $current_site->blog_id )
324 wpmu_delete_blog( $id, true );
326 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
331 if ( isset( $_POST['doaction']) || isset($_POST['doaction2'] ) ) {
332 check_admin_referer( 'bulk-ms-sites', '_wpnonce_bulk-ms-sites' );
334 if ( ! current_user_can( 'manage_sites' ) )
335 wp_die( __( 'You do not have permission to access this page.' ) );
337 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
338 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
341 foreach ( (array) $_POST['allblogs'] as $key => $val ) {
342 if ( $val != '0' && $val != $current_site->blog_id ) {
343 switch ( $doaction ) {
345 $blogfunction = 'all_delete';
346 wpmu_delete_blog( $val, true );
350 $blogfunction = 'all_spam';
351 update_blog_status( $val, 'spam', '1', 0 );
352 set_time_limit( 60 );
356 $blogfunction = 'all_notspam';
357 update_blog_status( $val, 'spam', '0', 0 );
358 set_time_limit( 60 );
362 wp_die( __( 'You are not allowed to change the current site.' ) );
366 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
369 wp_redirect( admin_url( 'ms-sites.php' ) );
374 check_admin_referer( 'archiveblog' );
375 if ( ! current_user_can( 'manage_sites' ) )
376 wp_die( __( 'You do not have permission to access this page.' ) );
378 update_blog_status( $id, 'archived', '1' );
379 do_action( 'archive_blog', $id );
380 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
384 case 'unarchiveblog':
385 check_admin_referer( 'unarchiveblog' );
386 if ( ! current_user_can( 'manage_sites' ) )
387 wp_die( __( 'You do not have permission to access this page.' ) );
389 do_action( 'unarchive_blog', $id );
390 update_blog_status( $id, 'archived', '0' );
391 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
396 check_admin_referer( 'activateblog' );
397 if ( ! current_user_can( 'manage_sites' ) )
398 wp_die( __( 'You do not have permission to access this page.' ) );
400 update_blog_status( $id, 'deleted', '0' );
401 do_action( 'activate_blog', $id );
402 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
406 case 'deactivateblog':
407 check_admin_referer( 'deactivateblog' );
408 if ( ! current_user_can( 'manage_sites' ) )
409 wp_die( __( 'You do not have permission to access this page.' ) );
411 do_action( 'deactivate_blog', $id );
412 update_blog_status( $id, 'deleted', '1' );
413 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
418 check_admin_referer( 'unspamblog' );
419 if ( ! current_user_can( 'manage_sites' ) )
420 wp_die( __( 'You do not have permission to access this page.' ) );
422 update_blog_status( $id, 'spam', '0' );
423 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
428 check_admin_referer( 'spamblog' );
429 if ( ! current_user_can( 'manage_sites' ) )
430 wp_die( __( 'You do not have permission to access this page.' ) );
432 update_blog_status( $id, 'spam', '1' );
433 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
439 if ( ! current_user_can( 'manage_network_themes' ) )
440 wp_die( __( 'You do not have permission to access this page.' ) );
442 if ( is_array( $_POST['theme'] ) ) {
443 $themes = get_themes();
445 $allowed_themes = array();
446 foreach ( (array) $themes as $key => $theme ) {
447 if ( $_POST['theme'][ esc_html( $theme['Stylesheet'] ) ] == 'enabled' )
448 $allowed_themes[ esc_html( $theme['Stylesheet'] ) ] = true;
450 update_site_option( 'allowedthemes', $allowed_themes );
452 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'themes' ), wp_get_referer() ) );
458 if ( !headers_sent() ) {
460 header( 'Content-Type: text/html; charset=utf-8' );
462 if ( $current_site->blog_id == $id )
463 wp_die( __( 'You are not allowed to change the current site.' ) );
465 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
466 <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
468 <title><?php _e( 'WordPress › Confirm your action' ); ?></title>
470 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
472 wp_admin_css( 'install', true );
473 wp_admin_css( 'ie', true );
477 <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1>
478 <form action="ms-edit.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
479 <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
480 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
481 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
482 <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
483 <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
484 <p class="submit"><input class="button" type="submit" value="<?php _e( 'Confirm' ); ?>" /></p>
493 if ( ! current_user_can( 'manage_network_users' ) )
494 wp_die( __( 'You do not have permission to access this page.' ) );
496 check_admin_referer( 'deleteuser' );
498 if ( $id != '0' && $id != '1' ) {
499 $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays
500 $title = __( 'Users' );
501 $parent_file = 'ms-admin.php';
502 require_once( 'admin-header.php' );
503 echo '<div class="wrap">';
504 confirm_delete_users( $_POST['allusers'] );
506 require_once( 'admin-footer.php' );
509 wp_redirect( admin_url( 'ms-users.php' ) );
514 if ( ! current_user_can( 'manage_network_users' ) )
515 wp_die( __( 'You do not have permission to access this page.' ) );
517 if ( isset( $_POST['doaction']) || isset($_POST['doaction2'] ) ) {
518 check_admin_referer( 'bulk-ms-users', '_wpnonce_bulk-ms-users' );
520 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
521 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
523 foreach ( (array) $_POST['allusers'] as $key => $val ) {
524 if ( !empty( $val ) ) {
525 switch ( $doaction ) {
527 $title = __( 'Users' );
528 $parent_file = 'ms-admin.php';
529 require_once( 'admin-header.php' );
530 echo '<div class="wrap">';
531 confirm_delete_users( $_POST['allusers'] );
533 require_once( 'admin-footer.php' );
538 $user = new WP_User( $val );
539 if ( in_array( $user->user_login, get_super_admins() ) )
540 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) );
542 $userfunction = 'all_spam';
543 $blogs = get_blogs_of_user( $val, true );
544 foreach ( (array) $blogs as $key => $details ) {
545 if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
546 update_blog_status( $details->userblog_id, 'spam', '1' );
548 update_user_status( $val, 'spam', '1', 1 );
552 $userfunction = 'all_notspam';
553 $blogs = get_blogs_of_user( $val, true );
554 foreach ( (array) $blogs as $key => $details )
555 update_blog_status( $details->userblog_id, 'spam', '0' );
557 update_user_status( $val, 'spam', '0', 1 );
563 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
566 wp_redirect( admin_url( 'ms-users.php' ) );
571 check_admin_referer( 'ms-users-delete' );
572 if ( ! current_user_can( 'manage_network_users' ) )
573 wp_die( __( 'You do not have permission to access this page.' ) );
575 if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) {
576 foreach ( $_POST['blog'] as $id => $users ) {
577 foreach ( $users as $blogid => $user_id ) {
578 if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] )
579 remove_user_from_blog( $id, $blogid, $user_id );
581 remove_user_from_blog( $id, $blogid );
586 if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) )
587 foreach( $_POST['user'] as $id ) {
588 wpmu_delete_user( $id );
593 $deletefunction = 'delete';
595 $deletefunction = 'all_delete';
597 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), admin_url( 'ms-users.php' ) ) );
601 check_admin_referer( 'add-user', '_wpnonce_add-user' );
602 if ( ! current_user_can( 'manage_network_users' ) )
603 wp_die( __( 'You do not have permission to access this page.' ) );
605 if ( is_array( $_POST['user'] ) == false )
606 wp_die( __( 'Cannot create an empty user.' ) );
607 $user = $_POST['user'];
608 if ( empty($user['username']) && empty($user['email']) )
609 wp_die( __( 'Missing username and email.' ) );
610 elseif ( empty($user['username']) )
611 wp_die( __( 'Missing username.' ) );
612 elseif ( empty($user['email']) )
613 wp_die( __( 'Missing email.' ) );
615 $password = wp_generate_password();
616 $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
618 if ( false == $user_id )
619 wp_die( __( 'Duplicated username or email address.' ) );
621 wp_new_user_notification( $user_id, $password );
623 if ( get_site_option( 'dashboard_blog' ) == false )
624 add_user_to_blog( $current_site->blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
626 add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
628 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add' ), wp_get_referer() ) );
633 wp_redirect( admin_url( 'ms-admin.php' ) );