function user_role_delete

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.

File

modules/user/user.module, line 3048
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);
  }

  // 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');
}

© 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.module/function/user_role_delete/7.x