1 user.module | user_role_delete($role_name) |
Delete a user role from database.
Parameters
string $role_name: The name of the role to be deleted.
File
- core/
modules/ user/ user.module, line 2645 - Enables the user registration and login system.
Code
function user_role_delete($role_name) {
$role = user_role_load($role_name);
// If this is the administrator role, explicitly set the "user_admin_role"
// attribute to "0" (disabled).
$system_config = config('system.core');
if ($role_name == $system_config->get('user_admin_role')) {
$system_config->set('user_admin_role', 0);
$system_config->save();
}
$user_config = config('user.role.' . $role_name);
$user_config->delete();
// Update the users who have this role set:
db_delete('users_roles')
->condition('role', $role_name)
->execute();
module_invoke_all('user_role_delete', $role);
// Clear the user access cache.
backdrop_static_reset('user_roles');
backdrop_static_reset('user_access');
}