Skip to content

Commit

Permalink
Fix to not remove WP caps from the administrator (#2115)
Browse files Browse the repository at this point in the history
* Don't remove wp caps from the administrator

* typo
  • Loading branch information
corsacca authored Jul 14, 2023
1 parent 69f5685 commit b093459
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dt-core/setup-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ function dt_setup_roles_and_permissions(){
}
}
}
//remove permissions if they are set by the $expected_roles
//remove permissions if they are not set by the $expected_roles
foreach ( $role->capabilities as $cap_key => $cap_grant ){
if ( $cap_grant === true && !isset( $expected_roles[$role_key]['permissions'][$cap_key] ) ){
if ( in_array( $role_key, [ 'administrator' ], true ) && !in_array( $cap_key, $dt_permissions, true ) ){
$wp_capabilities = dt_multi_role_get_wp_capabilities();
if ( in_array( $role_key, [ 'administrator' ], true ) && ( !in_array( $cap_key, $dt_permissions, true ) || in_array( $cap_key, $wp_capabilities, true ) ) ){
continue; //don't remove a non D.T cap from the administrator
}
$role->remove_cap( $cap_key );
Expand Down

0 comments on commit b093459

Please sign in to comment.