Description

This module writes the current timestamp value, per user, to the users_data table everytime hook_preprocess_page() is called.

This is a utility module intended for use with other modules. If you want or need a current timestamp written everytime a page is loaded per unique User ID, use this module.

Details


users_data row is written as:

function HOOK_preprocess_page() {
  \Drupal::service('user.data')
    ->set('page_access_user_data_timestamp', $UID, 'access_timestamp', time());
}

and can be accessed by:

function MYMODULE_getUserData() {
  return \Drupal::service('user.data');
}

function MYMODULE_preprocess_hook() {
  $paudt_Timestamp = MYMODULE_getUserData()
    ->get('page_access_user_data_timestamp', $UID, 'access_timestamp');
}

Example Module Use

User Active Indicator uses this module to show an active mark and timestamp next to user names.

Project information

Releases