Changeset 52823 for trunk/src/wp-includes/class-wp-user.php
- Timestamp:
- 03/06/2022 04:09:06 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-user.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-user.php
r51851 r52823 543 543 } 544 544 545 if ( in_array( $role, $this->roles, true ) ) { 546 return; 547 } 548 545 549 $this->caps[ $role ] = true; 546 550 update_user_meta( $this->ID, $this->cap_key, $this->caps ); … … 570 574 return; 571 575 } 576 572 577 unset( $this->caps[ $role ] ); 573 578 update_user_meta( $this->ID, $this->cap_key, $this->caps ); … … 607 612 608 613 $old_roles = $this->roles; 614 609 615 if ( ! empty( $role ) ) { 610 616 $this->caps[ $role ] = true; 611 617 $this->roles = array( $role => true ); 612 618 } else { 613 $this->roles = false; 614 } 619 $this->roles = array(); 620 } 621 615 622 update_user_meta( $this->ID, $this->cap_key, $this->caps ); 616 623 $this->get_role_caps(); 617 624 $this->update_user_level_from_caps(); 625 626 foreach ( $old_roles as $old_role ) { 627 if ( ! $old_role || $old_role === $role ) { 628 continue; 629 } 630 631 /** This action is documented in wp-includes/class-wp-user.php */ 632 do_action( 'remove_user_role', $this->ID, $old_role ); 633 } 634 635 if ( $role && ! in_array( $role, $old_roles, true ) ) { 636 /** This action is documented in wp-includes/class-wp-user.php */ 637 do_action( 'add_user_role', $this->ID, $role ); 638 } 618 639 619 640 /**
Note: See TracChangeset
for help on using the changeset viewer.