Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function user_role_delete

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 modules/comment/comment.test
Tests comment links.
user_admin_role_delete_confirm_submit in modules/user/user.admin.inc
Form submit handler for user_admin_role_delete_confirm().

File

modules/user/user.module, line 3092

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.