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 2380
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, delete the user_admin_role variable.
  if ($role_name == config_get('system.core', 'user_admin_role')) {
    $system_config = config('system.core');
    $system_config->clear('user_admin_role');
    $system_config->save();
  }

  $config = config('user.role.' . $role_name);
  $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');
}