• Resolved wwwilson

    (@wwwilson)


    Hello,

    I have used…

    GDPR::consent_checkboxes();

    …in my registration form which produced a list of form fields, however, I am struggling with validating them. On the front-end, validation works, but if I delete the checkbox in inspect I can still proceed with registration without selecting required fields. In my backend validation hook (using PMPRO plugin), I have tried

    if (!isset( $_REQUEST['privacy-policy'] )) {
    //do validation
    return false;
    }

    … which normally fires for other fields but is not picking up GDPR fields. I have tried changing the $_REQUEST to ‘user_consents[privacy-policy]’ and ‘privacy-policy-consent’ too but having no luck.

    Any ideas how I can fire validation for the consent_checkbox fields? Any help would be greatly appreciated!

    Cheers,

    Andrew

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter wwwilson

    (@wwwilson)

    On that note: It would also be great to know how I could pull a list of required fields at the backend too (so validation doesn’t have to be done manually each time).

    Plugin Author Fernando Claussen

    (@fclaussen)

    Hi @wwwilson,

    Sorry, it took me this long to reply. I didn’t notice your post until now.

    You should try $_POST['user_consents']. This will return an array. Each key is the consent ID.

    Regarding a way to get consents in the backend, you can do this: $consent_types = get_option( 'gdpr_consent_types', array() ); and filter with array_filter to only get the ones that are required if you want.

    I hope this helped.

    Plugin Author Fernando Claussen

    (@fclaussen)

    Kudos for adding a backend validation.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can’t validate consent_checkboxes fields’ is closed to new replies.