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.
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
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.
'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.
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?
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.
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?
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; }
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;
}
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.
Hi,
Our theme use custom template for commets form in file comments.php.
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.
Hi,
Please share admin and ftp access. We will try to inspect problem on your site.
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?
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
I changed it in comments.php of the main theme.
Where? I don't see any changes:
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.
We will be in touch for another 2-3 hours.
So do you want me to add it now?
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.
Fixed your code. Please check. Also added some code to custom css to correct display.
https://prnt.sc/ju23k2
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?
1. Select "All languages" in top admin panel.
2. Try to add "required" attribute to checkbox or use this example:
Also I recommend to copy current comments.php template to child theme because after theme update changes will be lost.
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:
What am I missing here? Wrong spot? Wrong code snippet?
Try to use example from here:
https://stackoverflow.com/questions/5884582/required-attribute-on-multiple-checkboxes-with-the-same-name
You need "required" attribute only
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?
I added next code to functions.php file in child theme
Did you make some other changes in main theme?No, just the comment.php
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.
Try to change code like this:
This worked perfectly! Thanks, Max!