Users: When creating the first user on installation, populate the Website profile field with the site URL.

Skip setting the field if the user already exists, which is the case when the user tables are being shared among multiple sites.

Props EFAREM, eclare, darrenlambert, zachflauaus, viralsampat.
Fixes #35778.
Built from https://develop.svn.wordpress.org/trunk@46989


git-svn-id: http://core.svn.wordpress.org/trunk@46789 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-12-18 02:26:03 +00:00
parent 694913d65f
commit 4edec193bc
2 changed files with 13 additions and 4 deletions

View File

@ -82,16 +82,20 @@ if ( ! function_exists( 'wp_install' ) ) :
$user_id = username_exists( $user_name );
$user_password = trim( $user_password );
$email_password = false;
$user_created = false;
if ( ! $user_id && empty( $user_password ) ) {
$user_password = wp_generate_password( 12, false );
$message = __( '<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.' );
$user_id = wp_create_user( $user_name, $user_password, $user_email );
update_user_option( $user_id, 'default_password_nag', true, true );
$email_password = true;
$user_created = true;
} elseif ( ! $user_id ) {
// Password has been provided
// Password has been provided.
$message = '<em>' . __( 'Your chosen password.' ) . '</em>';
$user_id = wp_create_user( $user_name, $user_password, $user_email );
$user_created = true;
} else {
$message = __( 'User already exists. Password inherited.' );
}
@ -99,6 +103,11 @@ if ( ! function_exists( 'wp_install' ) ) :
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
if ( $user_created ) {
$user->user_url = $guessurl;
wp_update_user( $user );
}
wp_install_defaults( $user_id );
wp_install_maybe_enable_pretty_permalinks();

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.4-alpha-46988';
$wp_version = '5.4-alpha-46989';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.