-
AuthorPosts
-
June 21, 2018 at 11:23 am #975751
Hi,
with your last update you provided a function to enable a checkbox for all comment forms on the website.
While enabling it, this checkbox didn’t show up at the form for product reviews on the product page within a woocommerce shop.
Is there a possibility to show a checkbox at the product review form?Thanks!
June 21, 2018 at 4:30 pm #975844Hi flipstar99!
Yes, please add this code to the child theme functions.php file:
add_action( 'comment_form', 'av_privacy_comment_checkbox_woo', 5 ); function av_privacy_comment_checkbox_woo() { if(!is_product()) return; remove_action('comment_form', 'show_subscription_checkbox'); if(is_user_logged_in()) return; $content = do_shortcode(avia_get_option('privacy_message')); $id = 'comment-form-av-privatepolicy'; $output = '<p class="form-av-privatepolicy ' . $id . '" style="margin: 10px 0;"> <input id="' . $id . '" name="' . $id . '" type="checkbox" value="yes"> <label for="' . $id . '">' . $content . '</label> <input type="hidden" name="fake-' . $id . '" value="fake-val">'; echo $output; } add_filter( 'preprocess_comment', 'av_privacy_verify_comment_checkbox_woo' ); function av_privacy_verify_comment_checkbox_woo( $commentdata ) { if ( ! is_user_logged_in() && isset( $_POST['fake-comment-form-av-privatepolicy'] ) && ! isset( $_POST['comment-form-av-privatepolicy'] ) ) { $error_message = apply_filters( 'avf_privacy_comment_checkbox_error_message', __( 'Error: You must agree to our privacy policy to comment on this site...' , 'avia_framework' ) ); wp_die( $error_message ); } return $commentdata; }
Cheers!
PeterJune 25, 2018 at 11:44 am #977377Hi Peter,
thanks for this.
I tested it and I can see the checkbox. But it’s possible to send the comment without checking the checkbox. Can you please check this?
And is it also possible to show this checkbox not only for guests but also for logged in users?Thanks a lot!
Matthias
June 25, 2018 at 8:58 pm #977640Hi,
To
make it
let u know if that works ;-)
Best regards,
BasilisJune 25, 2018 at 11:33 pm #977699June 26, 2018 at 11:12 am #977857June 27, 2018 at 12:19 pm #978376Thanks for help. Thread can be closed.
June 28, 2018 at 10:15 pm #979113Hi,
Thank you for letting us know.
Best regards,
Basilis -
AuthorPosts
- The topic ‘GDPR data privacy checkbox for product reviews’ is closed to new replies.