function facebook_tracking_pixel_user_registration in Facebook Tracking Pixel 7
Same name and namespace in other branches
- 8 facebook_tracking_pixel.admin.inc \facebook_tracking_pixel_user_registration()
Form builder for core modules settings.
1 string reference to 'facebook_tracking_pixel_user_registration'
- facebook_tracking_pixel_menu in ./
facebook_tracking_pixel.module - Implements hook_menu().
File
- ./
facebook_tracking_pixel.admin.inc, line 660 - facebook_tracking_pixel.admin.inc Admin pages.
Code
function facebook_tracking_pixel_user_registration($form, &$form_state) {
$form['intro'] = [
'#markup' => t('Enabling this will track user registration for the entire site. To not track users added by admins, do not enable tracking for their roles.'),
];
//Check to see if there are base codes.
$resultcountbasecode = db_select('facebook_tracking_pixel_base_codes', 'c')
->fields('c')
->countQuery()
->execute()
->fetchField();
if ($resultcountbasecode == 0) {
$form['emptyset'] = [
'#type' => 'hidden',
'#value' => TRUE,
];
$form['notice'] = [
'#markup' => t('You must first set a base code for tracking.'),
];
return $form;
}
else {
// If we have results then build an array to use as an option drop down for
// the path items.
$resultbasecode = db_select('facebook_tracking_pixel_base_codes', 'c')
->fields('c')
->orderBy('weight')
->execute()
->fetchAllAssoc('base_code_id');
$basecodes = [];
foreach ($resultbasecode as $item) {
$basecodes[$item->base_code_id] = $item->base_code_name;
}
}
$enable = variable_get('facebook_tracking_pixel_user_registration_enable', 0);
$form['facebook_tracking_pixel_user_registration_enable'] = [
'#title' => t('Enable the tracking of user registrations'),
'#type' => 'checkbox',
'#default_value' => $enable,
'#ajax' => [
'callback' => 'facebook_tracking_pixel_user_registration_ajax',
'wrapper' => 'replace-facebook-tracking-pixel-user-registration-basecodes',
'effect' => 'fade',
],
];
$form['facebook_tracking_pixel_user_registration_basecode'] = [
'#markup' => t('Enable user tracking to set basecode'),
// '#default_value' => variable_get('freshdesk_widget_popup_type_attribute'),
'#prefix' => '<div id="replace-facebook-tracking-pixel-user-registration-basecodes">',
'#suffix' => '</div>',
];
if (!empty($form_state['values']['facebook_tracking_pixel_user_registration_enable']) && $form_state['values']['facebook_tracking_pixel_user_registration_enable'] || $enable == 1) {
unset($form['facebook_tracking_pixel_user_registration_basecode']['#options']);
unset($form['facebook_tracking_pixel_user_registration_basecode']['#type']);
unset($form['facebook_tracking_pixel_user_registration_basecode']['#markup']);
$form['facebook_tracking_pixel_user_registration_basecode']['#type'] = 'select';
$form['facebook_tracking_pixel_user_registration_basecode']['#title'] = t('Facebook Base Tracking Code to Use');
$form['facebook_tracking_pixel_user_registration_basecode']['#options'] = $basecodes;
$form['facebook_tracking_pixel_user_registration_basecode']['#default_value'] = variable_get('facebook_tracking_pixel_user_registration_basecode', NULL);
}
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Save configuration',
];
return $form;
}