Take your website
To the next level
Discover our newly launched customization services and elevate your web projects to new heights.
Delegate tasks, save time, and unlock the power of professional WordPress outsourcing.

Okay
  Public Ticket #1594871
Comments GDPR
Closed

Comments

  •  2
    Natethenomad started the conversation

    I am trying to get a check box below my comment form (GDPR!!!). It is supposed to be there already with the latest Wordpress update. I now assume this Theme is not using the WP comment form and I don't know how to add this box on my own. Please help me. Either come up with a theme update ASAP or give me very detailed instructions on how to add a check box to acknowledge people who leave a comment that their data will be displayed on the website and saved for future. I want to customize the text on my own so I need to know how to deal with this. Thanks.

  • [deleted] replied

    Hi,

    Our theme use custom template for commets form in file comments.php.

  •  2
    Natethenomad replied

    I know and I tried to add the checkbox there. I used this article: http://www.wpbeginner.com/wp-themes/how-to-add-a-gdpr-comment-privacy-opt-in-checkbox-in-wordpress/
    But it didn't work. It made everything below "Related Posts" disappear. Can you provide a better source to solve this issue? It's been 2 weeks now since the GDPR law went into effect and I really have to add this checkbox.

  • [deleted] replied

    Hi,

    Please share admin and ftp access. We will try to inspect problem on your site.

  •   Natethenomad replied privately
  • [deleted] replied

    I don't see commets.php template in child theme or some changes in template in parent theme. Where did you make changes for display this checkbox?

  •  2
    Natethenomad replied

    I deleted it again, because it erased the whole bottom below "Related Posts" heading. I added the code from the link I send you in the previous message

  •  2
    Natethenomad replied

    I changed it in comments.php of the main theme.

  • [deleted] replied

    Where? I don't see any changes:


  •  2
    Natethenomad replied

    I never know when you guys are fixing things and help me. I am in US timezone and when I wake up, you almost stop working. I don't want that my site looks fucked up for almost a whole day. Therefore, I deleted it from the comments.php (main theme). If you promise me to fix it within the next hours I can add the code again. Or you add a checkbox above the "Submit Box" like you should have it anyway according to the GDPR.

  • [deleted] replied

    We will be in touch for another 2-3 hours.

  •  2
    Natethenomad replied

    So do you want me to add it now?

  •  2
    Natethenomad replied

    I added this:

    // Now we will add our new privacy checkbox optin
     
                    'cookies' => '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
                                                 '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>',
                    )
                ),


    The last time, I also tried to add a line within 'fields' => array (after author, email, url), but it didn't solve the problem.

  • [deleted] replied

    Fixed your code. Please check. Also added some code to custom css to correct display.

    https://prnt.sc/ju23k2

  •  2
    Natethenomad replied

    Thanks, Max! I checked the code and css. It works now.

    I tested commenting as well to see if it really works.

    1. WP gives me notifications about the pending comments, but they are not displayed on my WP panel (screenshot attached). It worked earlier today, because I had some pending spam comments etc before we started inserting this checkbox.

    2. Is there a way to make it a requirement like the Name and Comment?

  • [deleted] replied

    1. Select "All languages" in top admin panel.

    2. Try to add "required" attribute to checkbox or use this example:

    add_filter( 'preprocess_comment', 'verify_comment_meta_data' );
    function verify_comment_meta_data( $commentdata ) {
      if ( ! isset( $_POST['rating'] ) )
      wp_die( __( 'Error: You did not add a rating. Hit the Back button on your Web browser and resubmit your comment with a rating.' ) );
      return $commentdata;
    }


    Also I recommend to copy current comments.php template to child theme because after theme update changes will be lost.

  •  2
    Natethenomad replied

    1. OMG sorry for that, this was my stupidity :D

    2. I added this (after value="yes"' and before . $consent . ') but it didn't work:

    ($req ? ' aria-required="true"' : '').($req ? ' *' : '')
    

    What am I missing here? Wrong spot? Wrong code snippet?

  •  2
    Natethenomad replied

    I tried to use this, but it still allows to comment without checking the box. I also made a copy and added it into the child theme. Do I have to do anything else that it uses the child theme's comment.php? 

  • [deleted] replied

    I added next code to functions.php file in child theme

    add_filter( 'preprocess_comment', 'verify_comment_meta_data' );
    function verify_comment_meta_data( $commentdata ) {
      if ( ! isset( $_POST['wp-comment-cookies-consent'] ) )
      wp_die( __( 'Error: You did not check.' ) ); // CHANGE THIS TEXT
      return $commentdata;
    }
    Did you make some other changes in main theme?

  •  2
    Natethenomad replied

    No, just the comment.php

  •  2
    Natethenomad replied

    And I still found an error. I tried to reply to a comment and now it's telling me that I haven't checked the box... Screenshot attached.

  • [deleted] replied

    Try to change code like this:

    add_filter( 'preprocess_comment', 'verify_comment_meta_data' );
    function verify_comment_meta_data( $commentdata ) {
      if ( ! is_admin() && ! isset( $_POST['wp-comment-cookies-consent'] ) )
      wp_die( __( 'Error: You did not check.' ) ); // CHANGE THIS TEXT
      return $commentdata;
    }


  •  2
    Natethenomad replied

    This worked perfectly! Thanks, Max!