diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 3e2c9f6004..71a69aeb1f 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -256,6 +256,7 @@ function add_user() { } function edit_user($user_id = 0) { + global $current_user, $wp_roles; if ($user_id != 0) { $update = true; @@ -276,6 +277,14 @@ function edit_user($user_id = 0) { if (isset ($_POST['pass2'])) $pass2 = $_POST['pass2']; + if (isset ($_POST['role'])) { + if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) + $user->role = $_POST['role']; + } + + if (isset ($_POST['role'])) { + $user->role = $_POST['role']; + } if (isset ($_POST['email'])) $user->user_email = wp_specialchars(trim($_POST['email'])); if (isset ($_POST['url'])) { diff --git a/wp-admin/profile.php b/wp-admin/profile.php index 183908335b..2250a24df7 100644 --- a/wp-admin/profile.php +++ b/wp-admin/profile.php @@ -30,6 +30,10 @@ $bookmarklet_height= 440;
+ + + diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php index 13cb96451c..32cf47ac9b 100644 --- a/wp-admin/user-edit.php +++ b/wp-admin/user-edit.php @@ -82,6 +82,18 @@ if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permi + + + diff --git a/wp-includes/registration-functions.php b/wp-includes/registration-functions.php index a632fd8498..35e2cb4b68 100644 --- a/wp-includes/registration-functions.php +++ b/wp-includes/registration-functions.php @@ -59,7 +59,12 @@ function wp_insert_user($userdata) { update_usermeta( $user_id, 'jabber', $jabber ); update_usermeta( $user_id, 'aim', $aim ); update_usermeta( $user_id, 'yim', $yim ); - + + if ($update && !empty($role)) { + $user = new WP_User($user_id); + $user->set_role($role); + } + if ( !$update ) { $user = new WP_User($user_id); $user->set_role(get_settings('default_role'));