From 62b6474e771d3215f0d2b99a0d8c960fefe4e8b2 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 7 Nov 2012 17:16:37 +0000 Subject: [PATCH] When using WP_User::set_role() to set the role, don't unset all caps when the requested role matches the current role. Props scribu, jammitch fixes #18932 git-svn-id: https://develop.svn.wordpress.org/trunk@22418 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/capabilities.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index c8d730d53c..4f49ed98f6 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -797,12 +797,12 @@ class WP_User { * @param string $role Role name. */ function set_role( $role ) { - foreach ( (array) $this->roles as $oldrole ) - unset( $this->caps[$oldrole] ); - if ( 1 == count( $this->roles ) && $role == current( $this->roles ) ) return; + foreach ( (array) $this->roles as $oldrole ) + unset( $this->caps[$oldrole] ); + if ( !empty( $role ) ) { $this->caps[$role] = true; $this->roles = array( $role => true );