Plugin Author
Phil
(@philsbury)
Hi @amihaidany,
You should have it in the array
that is passed to the filter. Take this as an example:
add_filter('post_age_gate_custom_fields', 'my_custom_fields', 10, 1);
function my_custom_fields($fields)
{
$fields .= '<label><input type="checkbox" name="ag_field_terms" value="1" /> I accept the terms and conditions</label>';
return $fields;
}
add_filter('age_gate_form_success', function ($data) {
// $data['ag_field_terms'] will be the checkbox
});
Of course, if it is not checked it won’t be int the POST data, so you’d been to check if it’s set in data:
add_filter('age_gate_form_success', function ($data) {
if (isset($data['ag_field_terms']) {
// do stuff
}
});
If you’re still having issues, feel free to post some code up and I’ll have a look
Thanks
Phil
Hello Phil,
Thank you so much!
So, now the ultimate question is – can i modify the AJAX response from server, after aan age gate has been passed successfully?
Besides setting my own flags in the user session server side (after getting the custom fields data), i want to modify some elements in the same page, after the age gate passed. So i want to rely on the ‘agegatepassed’ JS event, and have the data of the custom fields inside the response.
If that’s possible via hooks .. You just saved me whole lotta time! 🙂
Didn’t find a hook of the JSON response though 🙁
Thank you!
-
This reply was modified 3 years, 2 months ago by
amihaidany.
Plugin Author
Phil
(@philsbury)
Hi @amihaidany,
There’s no hooks for that at the moment (I’ll make a note though!), but when agegatepassed
is triggered the form still exists so at that point you could do
(function($){
$(document).on('agegatepassed', function () {
console.log($('.age-gate-form').serializeArray());
});
})(jQuery);
and you’ll have all the form data
Hope that helps
Ta
Phil
Hey Phil,
Just wanted to say thank you so much once again, your support is amazing and i’m sure everyone here appreciate it. BIG UP!
Amihai
-
This reply was modified 3 years, 2 months ago by
amihaidany.
-
This reply was modified 3 years, 2 months ago by
amihaidany.