function user_role_delete
7.x user.module | user_role_delete($role) |
Delete a user role from database.
Parameters
$role: A string with the role name, or an integer with the role ID.
2 calls to user_role_delete()
- CommentInterfaceTest::testCommentLinks in drupal-7.x/
modules/ comment/ comment.test - Tests comment links.
- user_admin_role_delete_confirm_submit in drupal-7.x/
modules/ user/ user.admin.inc - Form submit handler for user_admin_role_delete_confirm().
File
- drupal-7.x/
modules/ user/ user.module, line 2993 - Enables the user registration and login system.
Code
function user_role_delete($role) {
if (is_int($role)) {
$role = user_role_load($role);
}
else {
$role = user_role_load_by_name($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');
}