Ensure we don't destory the $wp_roles->role_objects property when assigning a second role to a WP_User object. Fixes #9128 props dd32.
git-svn-id: http://svn.automattic.com/wordpress/trunk@12479 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e11e569611
commit
acd41194ff
|
@ -97,8 +97,7 @@ class WP_Roles {
|
|||
* @global array $wp_user_roles Used to set the 'roles' property value.
|
||||
*/
|
||||
function _init () {
|
||||
global $wpdb;
|
||||
global $wp_user_roles;
|
||||
global $wpdb, $wp_user_roles;
|
||||
$this->role_key = $wpdb->prefix . 'user_roles';
|
||||
if ( ! empty( $wp_user_roles ) ) {
|
||||
$this->roles = $wp_user_roles;
|
||||
|
@ -545,8 +544,8 @@ class WP_User {
|
|||
//Build $allcaps from role caps, overlay user's $caps
|
||||
$this->allcaps = array();
|
||||
foreach ( (array) $this->roles as $role ) {
|
||||
$role =& $wp_roles->get_role( $role );
|
||||
$this->allcaps = array_merge( (array) $this->allcaps, (array) $role->capabilities );
|
||||
$the_role =& $wp_roles->get_role( $role );
|
||||
$this->allcaps = array_merge( (array) $this->allcaps, (array) $the_role->capabilities );
|
||||
}
|
||||
$this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps );
|
||||
}
|
||||
|
@ -678,7 +677,8 @@ class WP_User {
|
|||
* @param string $cap Capability name.
|
||||
*/
|
||||
function remove_cap( $cap ) {
|
||||
if ( empty( $this->caps[$cap] ) ) return;
|
||||
if ( empty( $this->caps[$cap] ) )
|
||||
return;
|
||||
unset( $this->caps[$cap] );
|
||||
update_usermeta( $this->ID, $this->cap_key, $this->caps );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue