Ticket #18932: 18932.diff

File 18932.diff, 629 bytes (added by scribu, 19 months ago)
Line 
1diff --git wp-includes/capabilities.php wp-includes/capabilities.php
2index b93e2a8..69d637c 100644
3--- wp-includes/capabilities.php
4+++ wp-includes/capabilities.php
5@@ -718,12 +718,12 @@ class WP_User {
6         * @param string $role Role name.
7         */
8        function set_role( $role ) {
9-               foreach ( (array) $this->roles as $oldrole )
10-                       unset( $this->caps[$oldrole] );
11-
12                if ( 1 == count( $this->roles ) && $role == $this->roles[0] )
13                        return;
14 
15+               foreach ( (array) $this->roles as $oldrole )
16+                       unset( $this->caps[$oldrole] );
17+
18                if ( !empty( $role ) ) {
19                        $this->caps[$role] = true;
20                        $this->roles = array( $role => true );