function crazyegg_is_role_allowed in Crazy Egg Integration 8
Same name and namespace in other branches
- 7 crazyegg.module \crazyegg_is_role_allowed()
Check if actual user role is not mentioned in `crazyegg_roles_excluded` variable
Return value
bool
1 call to crazyegg_is_role_allowed()
- crazyegg_page_attachments in ./
crazyegg.module - Implements hook_page_attachments(). Checks all conditions and if they are met, injects Crazy Egg tracking script into the page
File
- ./
crazyegg.module, line 119
Code
function crazyegg_is_role_allowed() {
$current_user = User::load(\Drupal::currentUser()
->id());
$roles_excluded = \Drupal::config('crazyegg.settings')
->get('crazyegg_roles_excluded');
if ($roles_excluded) {
foreach ($roles_excluded as $role) {
if (!empty($role) and $current_user
->hasRole($role)) {
return FALSE;
}
}
}
return TRUE;
}