function _matomo_visibility_user in Matomo Analytics 8
Same name and namespace in other branches
- 7.2 matomo.module \_matomo_visibility_user()
Tracking visibility check for an user object.
Parameters
object $account: A user object containing an array of roles to check.
Return value
bool TRUE if the current user is being tracked by Matomo, otherwise FALSE.
1 call to _matomo_visibility_user()
- matomo_page_attachments in ./
matomo.module - Implements hook_page_attachments().
File
- ./
matomo.module, line 575 - Drupal Module: Matomo.
Code
function _matomo_visibility_user($account) {
$config = \Drupal::config('matomo.settings');
$enabled = FALSE;
// Is current user a member of a role that should be tracked?
if (_matomo_visibility_roles($account)) {
// Use the user's block visibility setting, if necessary.
if (($visibility_user_account_mode = $config
->get('visibility.user_account_mode')) != 0) {
$user_data_matomo = \Drupal::service('user.data')
->get('matomo', $account
->id());
if ($account
->id() && isset($user_data_matomo['user_account_users'])) {
$enabled = $user_data_matomo['user_account_users'];
}
else {
$enabled = $visibility_user_account_mode == 1;
}
}
else {
$enabled = TRUE;
}
}
return $enabled;
}