admin always can tnc_rep_edit_users #274
This commit is contained in:
parent
33afc168a6
commit
04ecefa297
|
@ -322,6 +322,14 @@ class Roles {
|
|||
|
||||
$requested_cap = $args[0];
|
||||
|
||||
// Administrators will always be able to edit users
|
||||
if ( $requested_cap == 'tnc_rep_edit_users' ) {
|
||||
if ( array_key_exists('edit_users', $allcaps) && $allcaps['edit_users'] === true ) {
|
||||
$allcaps['tnc_rep_edit_users'] = true;
|
||||
return $allcaps;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $caps as $cap ) {
|
||||
|
||||
if ( array_key_exists($cap, $allcaps) && $allcaps[$cap] === true ) {
|
||||
|
|
|
@ -1023,4 +1023,24 @@ class Capabilities extends TAINACAN_UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @group users
|
||||
*/
|
||||
public function test_admin_can_edit_user() {
|
||||
global $current_user;
|
||||
wp_set_current_user(1);
|
||||
|
||||
$this->assertTrue(current_user_can('edit_users'));
|
||||
$this->assertTrue(current_user_can('tnc_rep_edit_users'));
|
||||
|
||||
$admin = get_userdata(1);
|
||||
$admin->add_cap('manage_tainacan', false);
|
||||
$current_user = $admin;
|
||||
wp_set_current_user(1);
|
||||
|
||||
$this->assertFalse(current_user_can('manage_tainacan'));
|
||||
$this->assertTrue(current_user_can('edit_users'));
|
||||
$this->assertTrue(current_user_can('tnc_rep_edit_users'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue