public function SocialRemoveRoleUser::execute in Open Social 8.9
Same name and namespace in other branches
- 8.7 modules/social_features/social_user/src/Plugin/Action/SocialRemoveRoleUser.php \Drupal\social_user\Plugin\Action\SocialRemoveRoleUser::execute()
- 8.8 modules/social_features/social_user/src/Plugin/Action/SocialRemoveRoleUser.php \Drupal\social_user\Plugin\Action\SocialRemoveRoleUser::execute()
- 10.3.x modules/social_features/social_user/src/Plugin/Action/SocialRemoveRoleUser.php \Drupal\social_user\Plugin\Action\SocialRemoveRoleUser::execute()
- 10.0.x modules/social_features/social_user/src/Plugin/Action/SocialRemoveRoleUser.php \Drupal\social_user\Plugin\Action\SocialRemoveRoleUser::execute()
- 10.1.x modules/social_features/social_user/src/Plugin/Action/SocialRemoveRoleUser.php \Drupal\social_user\Plugin\Action\SocialRemoveRoleUser::execute()
- 10.2.x modules/social_features/social_user/src/Plugin/Action/SocialRemoveRoleUser.php \Drupal\social_user\Plugin\Action\SocialRemoveRoleUser::execute()
Executes the plugin.
Overrides ExecutableInterface::execute
File
- modules/
social_features/ social_user/ src/ Plugin/ Action/ SocialRemoveRoleUser.php, line 63
Class
- SocialRemoveRoleUser
- Removes a role from a user but restricted by role.
Namespace
Drupal\social_user\Plugin\ActionCode
public function execute($account = NULL) {
$rid = $this->configuration['rid'];
// Skip removing the role from the user if they already don't have it.
if ($account !== FALSE && $account
->hasRole($rid)) {
// For efficiency manually save the original account before applying
// any changes.
$account->original = clone $account;
$account
->removeRole($rid);
$account
->save();
}
}