| 484 | | if ( email_exists( $insert_post['user_email'] ) ) { |
| 485 | | $insert_post['user_email'] = 'imported_' . $insert_post['user_email']; |
| | 481 | $sanitized_user_login = sanitize_user( $insert_post['user_login'], true ); |
| | 482 | |
| | 483 | // Both return the user's ID on success, and false on failure. |
| | 484 | $user_exists = username_exists( $sanitized_user_login ); |
| | 485 | $email_exists = email_exists( $insert_post['user_email'] ); |
| | 486 | |
| | 487 | if ( $user_exists !== false && $email_exists !== false |
| | 488 | && $user_exists === $email_exists |
| | 489 | ) { |
| | 490 | // Update an existing user instead of inserting a new one. |
| | 491 | $insert_post['ID'] = $user_exists; |
| | 492 | } else { |
| | 493 | if ( $user_exists ) { |
| | 494 | $insert_post['user_login'] = 'imported_' . $sanitized_user_login; |
| | 495 | } |
| | 496 | |
| | 497 | if ( $email_exists ) { |
| | 498 | $insert_post['user_email'] = 'imported_' . $insert_post['user_email']; |
| | 499 | } |