3 namespace Drupal\user\Plugin\Action;
6 * Removes a role from a user.
9 * id = "user_remove_role_action",
10 * label = @Translation("Remove a role from the selected users"),
14 class RemoveRoleUser extends ChangeUserRoleBase {
19 public function execute($account = NULL) {
20 $rid = $this->configuration['rid'];
21 // Skip removing the role from the user if they already don't have it.
22 if ($account !== FALSE && $account->hasRole($rid)) {
23 // For efficiency manually save the original account before applying
25 $account->original = clone $account;
26 $account->removeRole($rid);