WordPress.org

Make WordPress Core

Ticket #2910: install.php.diff

File install.php.diff, 3.2 KB (added by darkfate, 8 years ago)

allow user the select username

  • install.php

     
    104104<td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td> 
    105105</tr> 
    106106<tr> 
     107<th><?php _e('Your username:'); ?></th> 
     108        <td><input name="admin_username" type="text" id="admin_username" size="25" /></td> 
     109</tr> 
     110<tr> 
    107111<th><?php _e('Your e-mail:'); ?></th> 
    108112        <td><input name="admin_email" type="text" id="admin_email" size="25" /></td> 
    109113</tr> 
     
    120124 
    121125// Fill in the data we gathered 
    122126$weblog_title = stripslashes($_POST['weblog_title']); 
     127$admin_username = stripslashes($_POST['admin_username']); 
    123128$admin_email = stripslashes($_POST['admin_email']); 
    124129// check e-mail address 
     130if (empty($admin_username)) { 
     131        die (__("<strong>ERROR</strong>: please type your username"));} 
    125132if (empty($admin_email)) { 
    126133        die (__("<strong>ERROR</strong>: please type your e-mail address")); 
    127134} else if (!is_email($admin_email)) { 
     
    177184$random_password = substr(md5(uniqid(microtime())), 0, 6); 
    178185$display_name_array = explode('@', $admin_email); 
    179186$display_name = $display_name_array[0]; 
    180 $wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, display_name, user_nicename) VALUES ( '1', 'admin', MD5('$random_password'), '$admin_email', NOW(), '$display_name', 'admin')"); 
     187$wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, display_name, user_nicename) VALUES ( '1', '$admin_username', MD5('$random_password'), '$admin_email', NOW(), '$display_name', '$admin_username')"); 
    181188$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}user_level', '10');"); 
    182189$admin_caps = serialize(array('administrator' => true)); 
    183190$wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}capabilities', '{$admin_caps}');"); 
     
    189196 
    190197You can log in to the administrator account with the following information: 
    191198 
    192 Username: admin 
     199Username: $admin_username 
    193200Password: %2\$s 
    194201 
    195202We hope you enjoy your new weblog. Thanks! 
     
    205212 
    206213<p><em><?php _e('Finished!'); ?></em></p> 
    207214 
    208 <p><?php printf(__('Now you can <a href="%1$s">log in</a> with the <strong>username</strong> "<code>admin</code>" and <strong>password</strong> "<code>%2$s</code>".'), '../wp-login.php', $random_password); ?></p> 
     215<p><?php printf(__('Now you can <a href="%1$s">log in</a> with the <strong>username</strong> "<code>'.$admin_username.'</code>" and <strong>password</strong> "<code>%2$s</code>".'), '../wp-login.php', $random_password); ?></p> 
    209216<p><?php _e('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you. If you lose it, you will have to delete the tables from the database yourself, and re-install WordPress. So to review:'); ?> 
    210217</p> 
    211218<dl> 
    212219<dt><?php _e('Username'); ?></dt> 
    213 <dd><code>admin</code></dd> 
     220<dd><code><?php echo $admin_username ?></code></dd> 
    214221<dt><?php _e('Password'); ?></dt> 
    215222<dd><code><?php echo $random_password; ?></code></dd> 
    216223        <dt><?php _e('Login address'); ?></dt>