Sure why not, i think it’s a mandatory thing to be compliant with GDPR
any way I solved it for now by adding:
add_action( 'woocommerce_register_form', 'razztech_add_registration_privacy_policy', 11 );
function razztech_add_registration_privacy_policy() {
woocommerce_form_field( 'privacy_policy_reg', array(
'type' => 'checkbox',
'class' => array('form-row privacy'),
'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
'required' => true,
'label' => 'Autorizzo il trattamento dei miei dati secondo la <a href="/privacy-policy">Privacy Policy</a> del sito, ai sensi del Regolamento 2016/679/UE (GDPR) ',
));
}
// Show error if user does not tick
add_filter( 'woocommerce_registration_errors', 'razztech_validate_privacy_registration', 10, 3 );
function razztech_validate_privacy_registration( $errors, $username, $email ) {
if ( ! is_checkout() ) {
if ( ! (int) isset( $_POST['privacy_policy_reg'] ) ) {
$errors->add( 'privacy_policy_reg_error', __( 'Devi accettare la privacy policy!', 'woocommerce' ) );
}
}
return $errors;
}