Give better instructions when installing over an existing users table. Fixes #9569 based on patch from coffee2code.

git-svn-id: http://svn.automattic.com/wordpress/trunk@11326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2009-05-14 06:54:33 +00:00
parent 55ce914fbc
commit 69333a5b1b
2 changed files with 10 additions and 6 deletions

View File

@ -20,7 +20,7 @@ require_once(ABSPATH . 'wp-admin/includes/schema.php');
if ( !function_exists('wp_install') ) : if ( !function_exists('wp_install') ) :
/** /**
* {@internal Missing Short Description}} * Installs the blog
* *
* {@internal Missing Long Description}} * {@internal Missing Long Description}}
* *
@ -31,7 +31,7 @@ if ( !function_exists('wp_install') ) :
* @param string $user_email User's email. * @param string $user_email User's email.
* @param bool $public Whether blog is public. * @param bool $public Whether blog is public.
* @param null $deprecated Optional. Not used. * @param null $deprecated Optional. Not used.
* @return array Array keys 'url', 'user_id', 'password'. * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
*/ */
function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') { function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') {
global $wp_rewrite; global $wp_rewrite;
@ -59,10 +59,12 @@ function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='
$user_id = username_exists($user_name); $user_id = username_exists($user_name);
if ( !$user_id ) { if ( !$user_id ) {
$random_password = wp_generate_password(); $random_password = wp_generate_password();
$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, $random_password, $user_email); $user_id = wp_create_user($user_name, $random_password, $user_email);
update_usermeta($user_id, 'default_password_nag', true); update_usermeta($user_id, 'default_password_nag', true);
} else { } else {
$random_password = __('User already exists. Password inherited.'); $random_password = '';
$message = __('User already exists. Password inherited.');
} }
$user = new WP_User($user_id); $user = new WP_User($user_id);
@ -76,7 +78,7 @@ function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='
wp_cache_flush(); wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password); return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password, 'password_message' => $message);
} }
endif; endif;

View File

@ -136,8 +136,10 @@ switch($step) {
</tr> </tr>
<tr> <tr>
<th><?php _e('Password'); ?></th> <th><?php _e('Password'); ?></th>
<td><code><?php echo $password; ?></code><br /> <td><?php if ( !empty( $password ) ) {
<?php echo '<p>'.__('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.').'</p>'; ?></td> echo '<code>'. $password .'</code><br />';
}
echo '<p>'. $password_message .'</p>'; ?></td>
</tr> </tr>
</table> </table>