function googleanalytics_user in Google Analytics 6
Same name and namespace in other branches
- 5 googleanalytics.module \googleanalytics_user()
- 6.4 googleanalytics.module \googleanalytics_user()
- 6.2 googleanalytics.module \googleanalytics_user()
- 6.3 googleanalytics.module \googleanalytics_user()
Implementation of hook_user().
Allow users to decide if tracking code will be added to pages or not.
File
- ./
googleanalytics.module, line 217
Code
function googleanalytics_user($type, $edit, &$account, $category = NULL) {
switch ($type) {
case 'form':
if ($category == 'account' && user_access('opt-in or out of tracking') && ($custom = variable_get('googleanalytics_custom', 0)) != 0 && _googleanalytics_visibility_roles($account)) {
$form['googleanalytics'] = array(
'#type' => 'fieldset',
'#title' => t('Google Analytics configuration'),
'#weight' => 3,
'#collapsible' => TRUE,
'#tree' => TRUE,
);
switch ($custom) {
case 1:
$title = t('Disable user tracking');
$description = t('Users are tracked by default, but you are able to opt out.');
break;
case 2:
$title = t('Enable user tracking');
$description = t('Users are <em>not</em> tracked by default, but you are able to opt in.');
break;
}
$form['googleanalytics']['custom'] = array(
'#type' => 'checkbox',
'#title' => $title,
'#description' => $description,
'#default_value' => isset($account->googleanalytics['custom']) ? $account->googleanalytics['custom'] : $custom == 1,
);
return $form;
}
break;
}
}