You are here

public function RoleExpireApiService::deleteUserRecords in Role Expire 2.x

Same name and namespace in other branches
  1. 8 src/RoleExpireApiService.php \Drupal\role_expire\RoleExpireApiService::deleteUserRecords()

Delete all user expirations.

Parameters

int $uid: User ID.

bool $delete_session: Whether to terminate user session or not.

File

src/RoleExpireApiService.php, line 143

Class

RoleExpireApiService
Class RoleExpireApiService.

Namespace

Drupal\role_expire

Code

public function deleteUserRecords($uid, $delete_session = TRUE) {
  $this->database
    ->delete('role_expire')
    ->condition('uid', $uid)
    ->execute();
  if ($delete_session) {

    // Delete the user's sessions so they have login again with their new access.
    $this->sessionManager
      ->delete($uid);
  }
}