function hook_user_role_delete

hook_user_role_delete($role)

Respond to user role deletion.

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

File

modules/user/user.api.php, line 468
Hooks provided by the User module.

Code

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

© 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/modules!user!user.api.php/function/hook_user_role_delete/7.x