WordPress.org

Make WordPress Core

Changeset 46989


Ignore:
Timestamp:
12/18/2019 02:24:05 AM (5 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/upgrade.php

    r46972 r46989  
    8383        $user_password  = trim( $user_password );
    8484        $email_password = false;
     85        $user_created   = false;
     86
    8587        if ( ! $user_id && empty( $user_password ) ) {
    8688            $user_password = wp_generate_password( 12, false );
     
    8991            update_user_option( $user_id, 'default_password_nag', true, true );
    9092            $email_password = true;
     93            $user_created   = true;
    9194        } elseif ( ! $user_id ) {
    92             // Password has been provided
    93             $message = '<em>' . __( 'Your chosen password.' ) . '</em>';
    94             $user_id = wp_create_user( $user_name, $user_password, $user_email );
     95            // Password has been provided.
     96            $message      = '<em>' . __( 'Your chosen password.' ) . '</em>';
     97            $user_id      = wp_create_user( $user_name, $user_password, $user_email );
     98            $user_created = true;
    9599        } else {
    96100            $message = __( 'User already exists. Password inherited.' );
     
    99103        $user = new WP_User( $user_id );
    100104        $user->set_role( 'administrator' );
     105
     106        if ( $user_created ) {
     107            $user->user_url = $guessurl;
     108            wp_update_user( $user );
     109        }
    101110
    102111        wp_install_defaults( $user_id );
Note: See TracChangeset for help on using the changeset viewer.