67 if ( isset( $_POST['url'] ) ) { |
67 if ( isset( $_POST['url'] ) ) { |
68 if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) { |
68 if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) { |
69 $user->user_url = ''; |
69 $user->user_url = ''; |
70 } else { |
70 } else { |
71 $user->user_url = esc_url_raw( $_POST['url'] ); |
71 $user->user_url = esc_url_raw( $_POST['url'] ); |
72 $user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; |
72 $protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) ); |
|
73 $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; |
73 } |
74 } |
74 } |
75 } |
75 if ( isset( $_POST['first_name'] ) ) |
76 if ( isset( $_POST['first_name'] ) ) |
76 $user->first_name = sanitize_text_field( $_POST['first_name'] ); |
77 $user->first_name = sanitize_text_field( $_POST['first_name'] ); |
77 if ( isset( $_POST['last_name'] ) ) |
78 if ( isset( $_POST['last_name'] ) ) |
141 |
142 |
142 /* checking e-mail address */ |
143 /* checking e-mail address */ |
143 if ( empty( $user->user_email ) ) { |
144 if ( empty( $user->user_email ) ) { |
144 $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); |
145 $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) ); |
145 } elseif ( !is_email( $user->user_email ) ) { |
146 } elseif ( !is_email( $user->user_email ) ) { |
146 $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The e-mail address isn’t correct.' ), array( 'form-field' => 'email' ) ); |
147 $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn’t correct.' ), array( 'form-field' => 'email' ) ); |
147 } elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update || ( $owner_id != $user->ID ) ) ) { |
148 } elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update || ( $owner_id != $user->ID ) ) ) { |
148 $errors->add( 'email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) ); |
149 $errors->add( 'email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) ); |
149 } |
150 } |
150 |
151 |
151 // Allow plugins to return their own errors. |
152 // Allow plugins to return their own errors. |
195 * |
196 * |
196 * @param int $user_id User ID. |
197 * @param int $user_id User ID. |
197 * @return object WP_User object with user data. |
198 * @return object WP_User object with user data. |
198 */ |
199 */ |
199 function get_user_to_edit( $user_id ) { |
200 function get_user_to_edit( $user_id ) { |
200 $user = new WP_User( $user_id ); |
201 $user = get_userdata( $user_id ); |
201 |
202 |
202 $user->filter = 'edit'; |
203 $user->filter = 'edit'; |
203 |
204 |
204 return $user; |
205 return $user; |
205 } |
206 } |
267 foreach ( $link_ids as $link_id ) |
268 foreach ( $link_ids as $link_id ) |
268 wp_delete_link($link_id); |
269 wp_delete_link($link_id); |
269 } |
270 } |
270 } else { |
271 } else { |
271 $reassign = (int) $reassign; |
272 $reassign = (int) $reassign; |
|
273 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); |
272 $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) ); |
274 $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) ); |
|
275 if ( ! empty( $post_ids ) ) { |
|
276 foreach ( $post_ids as $post_id ) |
|
277 clean_post_cache( $post_id ); |
|
278 } |
|
279 $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); |
273 $wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) ); |
280 $wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) ); |
|
281 if ( ! empty( $link_ids ) ) { |
|
282 foreach ( $link_ids as $link_id ) |
|
283 clean_bookmark_cache( $link_id ); |
|
284 } |
274 } |
285 } |
275 |
286 |
276 // FINALLY, delete user |
287 // FINALLY, delete user |
277 if ( is_multisite() ) { |
288 if ( is_multisite() ) { |
278 remove_user_from_blog( $id, get_current_blog_id() ); |
289 remove_user_from_blog( $id, get_current_blog_id() ); |
350 echo '<div class="error default-password-nag">'; |
361 echo '<div class="error default-password-nag">'; |
351 echo '<p>'; |
362 echo '<p>'; |
352 echo '<strong>' . __('Notice:') . '</strong> '; |
363 echo '<strong>' . __('Notice:') . '</strong> '; |
353 _e('You’re using the auto-generated password for your account. Would you like to change it to something easier to remember?'); |
364 _e('You’re using the auto-generated password for your account. Would you like to change it to something easier to remember?'); |
354 echo '</p><p>'; |
365 echo '</p><p>'; |
355 printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', admin_url('profile.php') . '#password' ); |
366 printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', get_edit_profile_url( get_current_user_id() ) . '#password' ); |
356 printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' ); |
367 printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' ); |
357 echo '</p></div>'; |
368 echo '</p></div>'; |
358 } |
369 } |