From 7a732e3f20629b489d595007bcb3eefa726a2193 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 4 Apr 2006 02:26:02 +0000 Subject: [PATCH] Accommodate multi-blog setups that share user tables by checking to see if the admin user already exists during install. git-svn-id: https://develop.svn.wordpress.org/trunk@3692 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/upgrade-functions.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 160360b2c4..ce7b89cfbc 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -27,9 +27,16 @@ function wp_install($blog_title, $user_name, $user_email, $public, $meta='') { if ( ! $public ) update_option('default_pingback_flag', 0); - // Create default user. - $random_password = substr(md5(uniqid(microtime())), 0, 6); - $user_id = wp_create_user($user_name, $random_password, $user_email); + // Create default user. If the user already exists, the user tables are + // being shared among blogs. Just set the role in that case. + $user_id = username_exists($user_name); + if ( !$user_id ) { + $random_password = substr(md5(uniqid(microtime())), 0, 6); + $user_id = wp_create_user($user_name, $random_password, $user_email); + } else { + $random_password = __('User already exists. Password inherited.'); + } + $user = new WP_User($user_id); $user->set_role('administrator');