hook_user_role_delete

  1. drupal
    1. 8
    2. 7
Versions
8 – 7 hook_user_role_delete($role)

Inform other modules that a user role has been deleted.

This hook allows you act when a user role has been deleted. If your module stores references to roles, it's recommended that you implement this hook and delete existing instances of the deleted role in your module database tables.

Parameters

$role The $role object being deleted.

Related topics

Code

modules/user/user.api.php, line 441

<?php
function hook_user_role_delete($role) {
  // Delete existing instances of the deleted role.
  db_delete('my_module_table')
    ->condition('rid', $role->rid)
    ->execute();
}
?>