From d592888f36b0c9887e1f14f1b1b2c2e7637f92d5 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 18 Dec 2019 02:24:05 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@46989 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/upgrade.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 9bdc2e77ed..df3b8edcc3 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -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 = __( 'Note that password carefully! It is a random 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 - $message = '' . __( 'Your chosen password.' ) . ''; - $user_id = wp_create_user( $user_name, $user_password, $user_email ); + // Password has been provided. + $message = '' . __( 'Your chosen password.' ) . ''; + $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();