I have been trying to add a GDPR compliant checkbox/tickbox to the ajax signup form without success and wondered if anyone else has done it successfully (including validation) and can share their code please.
The "Subscribe via AJAX" demo does not have a GDPR checkbox. Please let us know how you added the GDPR checkbox in your code so that we could help debug.
Hi Ian, I haven't added one, that's what I want to do and wondered if anyone else had done it and could share their code to achieve this as it's a pretty standard requirement now for all forms.
Thanks
@Ben, Currently, the API does not echo an error message when the GDPR checkbox is not checked. Could you please make it echo an error message when the GDPR checkbox is not checked?
If you are coding a custom form that utilizes the 'subscribe' API, you'd need to write code to validate any additional inputs via your backend code before calling the 'subscribe' API.
@Ben, Thanks. Currently, only Ready-to-Use Subscribe Forms display the Consent not given. message when the GDPR checkbox is not checked. Would you please consider making that message one of the built-in messages of the Subscribe API in a future release?
6. And then adding this else if statement among the existing ones in the JavaScript:
else if(data=="Consent not given.")
{
$("#status").text('Please check the "Marketing permission" checkbox.'); // You can modify this message.
$("#status").css("color", "red");
}
Comments
If you don't mind letting us see a simplified version of your code, we could help you debug more easily by checking the simplified code.
H Ian,
the code is the one supplied by Sendy on this page - https://sendy.co/api
It's the "Subscribe via AJAX" whic links to this download - https://dl.dropboxusercontent.com/s/6ilix20ri3l3esu/Subscribe via AJAX.zip?token_hash=AAEE0bgEBCgeihVg1gVfCUpJ4hFKtWb0lqPfJiTFCJbSpQ&dl=1
Thanks
The "Subscribe via AJAX" demo does not have a GDPR checkbox. Please let us know how you added the GDPR checkbox in your code so that we could help debug.
Hi Ian, I haven't added one, that's what I want to do and wondered if anyone else had done it and could share their code to achieve this as it's a pretty standard requirement now for all forms.
Thanks
@Ben, Currently, the API does not echo an error message when the GDPR checkbox is not checked. Could you please make it echo an error message when the GDPR checkbox is not checked?
If you are coding a custom form that utilizes the 'subscribe' API, you'd need to write code to validate any additional inputs via your backend code before calling the 'subscribe' API.
@Ben, Thanks. Currently, only Ready-to-Use Subscribe Forms display the
Consent not given.
message when the GDPR checkbox is not checked. Would you please consider making that message one of the built-in messages of the Subscribe API in a future release?@frankie, In the mean time, you may implement the feature by:
1. Adding a checkbox in the HTML (with a
label
element, of course):2. Adding this
if
statement at the beginning of the PHP:3. Adding this new key/value pair into the
$postdata
array in the PHP:4. Adding this new line as the line 8 in the JavaScript:
5. Changing the line 11 of the JavaScript to:
6. And then adding this
else if
statement among the existing ones in the JavaScript: