Ticket #3144: trac-3144-2-user-import-set-display-name-to-original.patch
File trac-3144-2-user-import-set-display-name-to-original.patch, 2.2 KB (added by , 7 years ago) |
---|
-
src/includes/admin/classes/class-bbp-converter-base.php
477 477 /** New user **************************************/ 478 478 479 479 case 'user': 480 if ( username_exists( $insert_post['user_login'] ) ) {481 $insert_post['user_login'] = 'imported_' . $insert_post['user_login'];482 }483 480 484 if ( email_exists( $insert_post['user_email'] ) ) { 485 $insert_post['user_email'] = 'imported_' . $insert_post['user_email']; 481 $old_user_login = $insert_post['user_login']; 482 $sanitized_user_login = sanitize_user( $insert_post['user_login'], true ); 483 484 // Both return the user's ID on success, and false on failure. 485 $user_exists = username_exists( $sanitized_user_login ); 486 $email_exists = email_exists( $insert_post['user_email'] ); 487 488 if ( $user_exists !== false && $email_exists !== false 489 && $user_exists === $email_exists 490 ) { 491 // Update an existing user instead of inserting a new one. 492 $insert_post['ID'] = $user_exists; 493 } else { 494 if ( $user_exists ) { 495 $insert_post['user_login'] = 'imported_' . $sanitized_user_login; 496 } 497 498 if ( $email_exists ) { 499 $insert_post['user_email'] = 'imported_' . $insert_post['user_email']; 500 } 486 501 } 487 502 488 503 if ( empty( $insert_post['user_pass'] ) ) { … … 489 504 $insert_post['user_pass'] = ''; 490 505 } 491 506 507 if ( $sanitized_user_login !== $old_user_login 508 && empty( $insert_post['display_name'] ) 509 ) { 510 $insert_post['display_name'] = $old_user_login; 511 } 512 492 513 $post_id = wp_insert_user( $insert_post ); 493 514 494 515 if ( is_numeric( $post_id ) ) { … … 502 523 } 503 524 } 504 525 } 526 527 unset( $old_user_login, $sanitized_user_login, $user_exists, $email_exists ); 505 528 break; 506 529 507 530 /** New Topic-Tag *********************************/