/** * Implements hook_user_logout(). */ function {{ machine_name }}_user_logout(AccountInterface $account) { \Drupal::database()->insert('logouts') ->fields([ 'uid' => $account->id(), 'time' => time(), ]) ->execute(); }