Better handling of users with no role. Props Mark Jaquith. #2809
git-svn-id: http://svn.automattic.com/wordpress/trunk@3859 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -174,7 +174,7 @@ class WP_User {
|
||||
|
||||
//Build $allcaps from role caps, overlay user's $caps
|
||||
$this->allcaps = array();
|
||||
foreach($this->roles as $role) {
|
||||
foreach( (array) $this->roles as $role) {
|
||||
$role = $wp_roles->get_role($role);
|
||||
$this->allcaps = array_merge($this->allcaps, $role->capabilities);
|
||||
}
|
||||
@@ -199,8 +199,12 @@ class WP_User {
|
||||
function set_role($role) {
|
||||
foreach($this->roles as $oldrole)
|
||||
unset($this->caps[$oldrole]);
|
||||
$this->caps[$role] = true;
|
||||
$this->roles = array($role => true);
|
||||
if ( !empty($role) ) {
|
||||
$this->caps[$role] = true;
|
||||
$this->roles = array($role => true);
|
||||
} else {
|
||||
$this->roles = false;
|
||||
}
|
||||
update_usermeta($this->id, $this->cap_key, $this->caps);
|
||||
$this->get_role_caps();
|
||||
$this->update_user_level_from_caps();
|
||||
|
||||
@@ -102,7 +102,7 @@ function wp_insert_user($userdata) {
|
||||
update_usermeta( $user_id, 'aim', $aim );
|
||||
update_usermeta( $user_id, 'yim', $yim );
|
||||
|
||||
if ($update && !empty($role)) {
|
||||
if ( $update ) {
|
||||
$user = new WP_User($user_id);
|
||||
$user->set_role($role);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user