Delete a user role from database.
$role: A string with the role name, or an integer with the role ID.
function user_role_delete($role) {
if (is_int($role)) {
$role = user_role_load($role);
}
else {
$role = user_role_load_by_name($role);
}
// If this is the administrator role, delete the user_admin_role variable.
if ($role->rid == variable_get('user_admin_role')) {
variable_del('user_admin_role');
}
db_delete('role')
->condition('rid', $role->rid)
->execute();
db_delete('role_permission')
->condition('rid', $role->rid)
->execute();
// Update the users who have this role set:
db_delete('users_roles')
->condition('rid', $role->rid)
->execute();
module_invoke_all('user_role_delete', $role);
// Clear the user access cache.
drupal_static_reset('user_access');
drupal_static_reset('user_role_permissions');
}