You are here

function hook_user_logout in Drupal 7

Same name and namespace in other branches
  1. 8 core/modules/user/user.api.php \hook_user_logout()
  2. 9 core/modules/user/user.api.php \hook_user_logout()

The user just logged out.

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and user_save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check user_save() and db_transaction() for more info.

Parameters

$account: The user object on which the operation was just performed.

Related topics

2 functions implement hook_user_logout()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

openid_user_logout in modules/openid/openid.module
Implements hook_user_logout().
trigger_user_logout in modules/trigger/trigger.module
Implements hook_user_logout().
1 invocation of hook_user_logout()
user_logout_current_user in modules/user/user.pages.inc
Logs the current user out.

File

modules/user/user.api.php, line 331
Hooks provided by the User module.

Code

function hook_user_logout($account) {
  db_insert('logouts')
    ->fields(array(
    'uid' => $account->uid,
    'time' => time(),
  ))
    ->execute();
}