function facebook_pixel_user_visibility in Facebook Pixel 7
Utility function to perform tracking visibility check for a user.
Parameters
object $user: a user object containing an array of roles to check.
Return value
boolean whether or not the current user should be served the pixel.
1 call to facebook_pixel_user_visibility()
- facebook_pixel_preprocess_page in ./
facebook_pixel.module - Implements hook_preprocess_page().
File
- ./
facebook_pixel.module, line 235 - Drupal Module: Facebook Pixel.
Code
function facebook_pixel_user_visibility($user) {
$visible = TRUE;
$roles = variable_get('facebook_pixel_roles', array());
if (array_sum($roles) > 0) {
// One or more roles are selected for tracking.
foreach (array_keys($user->roles) as $rid) {
// Is the current user a member of a role selected in settings?
if (isset($roles[$rid]) && $rid == $roles[$rid]) {
// Current user is a member of a role that is selected in settings.
$visible = FALSE;
break;
}
}
}
return $visible;
}