WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/14/2010 03:07:47 AM (10 years ago)
Author:
dd32
Message:

First pass at allowing username/password selection upon install. Includes some extra cleanup of the patch. Props dancole. See #10396

File:
1 edited

Legend:

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

    r13067 r13134  
    3232 * @param bool $public Whether blog is public.
    3333 * @param null $deprecated Optional. Not used.
     34 * @param string $user_password Optional. User's chosen password. Will default to a random password.
    3435 * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
    3536 */
    36 function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '' ) {
     37function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '' ) {
    3738    global $wp_rewrite;
    3839
     
    6162    // being shared among blogs.  Just set the role in that case.
    6263    $user_id = username_exists($user_name);
    63     if ( !$user_id ) {
    64         $random_password = wp_generate_password();
     64    $user_password = trim($user_password);
     65    if ( !$user_id && empty($user_password) ) {
     66        $user_password = wp_generate_password();
    6567        $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
    66         $user_id = wp_create_user($user_name, $random_password, $user_email);
    67         update_user_option($user_id, 'default_password_nag', true, true);
     68        $user_id = wp_create_user($user_name, $user_password, $user_email);
     69        update_user_option($user_id, 'default_password_nag', true);
     70    } else if ( !$user_id ) {
     71        $message = __('<strong><em>Note that password</em></strong> carefully!');
     72        $user_id = wp_create_user($user_name, $user_password, $user_email);
    6873    } else {
    69         $random_password = '';
    7074        $message =  __('User already exists.  Password inherited.');
    7175    }
     
    7882    $wp_rewrite->flush_rules();
    7983
    80     wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
     84    wp_new_blog_notification($blog_title, $guessurl, $user_id, $user_password);
    8185
    8286    wp_cache_flush();
    8387
    84     return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password, 'password_message' => $message);
     88    return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
    8589}
    8690endif;
Note: See TracChangeset for help on using the changeset viewer.