Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Issue #98 - Added error message when we try to remove capability same…
… as role
  • Loading branch information
BhargavBhandari90 committed Apr 5, 2025
commit c21ba54339d8f88d4e0c5b3a2967892502dae798
4 changes: 4 additions & 0 deletions src/User_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,10 @@ public function remove_cap( $args, $assoc_args ) {
}
WP_CLI::error( "No such '{$cap}' cap for {$user->user_login} ({$user->ID})." );
}
$user_roles = $user->roles;
if ( ! empty( $user_role ) && in_array( $cap, $user_roles, true ) ) {
WP_CLI::error( "There is a role similar to '{$cap}' capability. Use `wp user remove-role` instead." );
}
$user->remove_cap( $cap );

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