Changes in trunk/wp-admin/network/user-new.php [17144:18131]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/network/user-new.php
r17144 r18131 19 19 20 20 add_contextual_help($current_screen, 21 '<p>' . __('Add User will set up a new user account on the network and send th em an email with theirusername and password.') . '</p>' .21 '<p>' . __('Add User will set up a new user account on the network and send that person an email with username and password.') . '</p>' . 22 22 '<p>' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '</p>' . 23 23 '<p><strong>' . __('For more information:') . '</strong></p>' . … … 31 31 wp_die( __( 'You do not have permission to access this page.' ) ); 32 32 33 if ( is_array( $_POST['user'] ) == false)33 if ( ! is_array( $_POST['user'] ) ) 34 34 wp_die( __( 'Cannot create an empty user.' ) ); 35 35 36 $user = $_POST['user']; 36 if ( empty($user['username']) && empty($user['email']) )37 wp_die( __( 'Missing username and email.' ) );38 elseif ( empty($user['username']) )39 wp_die( __( 'Missing username.' ) );40 elseif ( empty($user['email']) )41 wp_die( __( 'Missing email.' ) );42 37 43 $password = wp_generate_password( 12, false); 44 $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) ); 38 $user_details = wpmu_validate_user_signup( $user['username'], $user['email'] ); 39 if ( is_wp_error( $user_details[ 'errors' ] ) && ! empty( $user_details[ 'errors' ]->errors ) ) { 40 $add_user_errors = $user_details[ 'errors' ]; 41 } else { 42 $password = wp_generate_password( 12, false); 43 $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) ); 45 44 46 if ( false == $user_id ) 47 wp_die( __( 'Duplicated username or email address.' ) ); 48 else 49 wp_new_user_notification( $user_id, $password ); 50 51 wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) ); 52 exit; 45 if ( ! $user_id ) { 46 $add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) ); 47 } else { 48 wp_new_user_notification( $user_id, $password ); 49 wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) ); 50 exit; 51 } 52 } 53 53 } 54 54 … … 71 71 foreach ( $messages as $msg ) 72 72 echo '<div id="message" class="updated"><p>' . $msg . '</p></div>'; 73 } ?> 73 } 74 75 if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) { ?> 76 <div class="error"> 77 <?php 78 foreach ( $add_user_errors->get_error_messages() as $message ) 79 echo "<p>$message</p>"; 80 ?> 81 </div> 82 <?php } ?> 74 83 <form action="<?php echo network_admin_url('user-new.php?action=add-user'); ?>" id="adduser" method="post"> 75 84 <table class="form-table">
Note: See TracChangeset
for help on using the changeset viewer.