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: http://core.svn.wordpress.org/trunk@22418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
711f6f2619
commit
fac33f51fa
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue