function user_user_role_delete
user_user_role_delete(RoleInterface $role)
Implements hook_ENTITY_TYPE_delete() for user_role entities.
File
- core/modules/user/user.module, line 1017
- Enables the user registration and login system.
Code
function user_user_role_delete(RoleInterface $role) { // Delete role references for all users. $user_storage = \Drupal::entityManager()->getStorage('user'); $user_storage->deleteRoleReferences(array($role->id())); // Ignore the authenticated and anonymous roles or the role is being synced. if (in_array($role->id(), array(RoleInterface::AUTHENTICATED_ID, RoleInterface::ANONYMOUS_ID)) || $role->isSyncing()) { return; } $actions = entity_load_multiple('action', array( 'user_add_role_action.' . $role->id(), 'user_remove_role_action.' . $role->id(), )); foreach ($actions as $action) { $action->delete(); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!user!user.module/function/user_user_role_delete/8.1.x