Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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!

    #975844

    Hi 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!
    Peter

    #977377

    Hi 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

    #977640

    Hi,

    To

    make it

    let u know if that works ;-)

    Best regards,
    Basilis

    #977699

    #977857

    #978376

    Thanks for help. Thread can be closed.

    #979113

    Hi,

    Thank you for letting us know.

    Best regards,
    Basilis

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘GDPR data privacy checkbox for product reviews’ is closed to new replies.