Skip to content

Commit c21ba54

Browse files
Issue #98 - Added error message when we try to remove capability same as role
1 parent 66f76e4 commit c21ba54

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/User_Command.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,10 @@ public function remove_cap( $args, $assoc_args ) {
884884
}
885885
WP_CLI::error( "No such '{$cap}' cap for {$user->user_login} ({$user->ID})." );
886886
}
887+
$user_roles = $user->roles;
888+
if ( ! empty( $user_role ) && in_array( $cap, $user_roles, true ) ) {
889+
WP_CLI::error( "There is a role similar to '{$cap}' capability. Use `wp user remove-role` instead." );
890+
}
887891
$user->remove_cap( $cap );
888892

889893
WP_CLI::success( "Removed '{$cap}' cap for {$user->user_login} ({$user->ID})." );

0 commit comments

Comments
 (0)