Hi guys!!
Is it possible to display a custom error page for not accepting the privacy policy under WordPress comments? I know this is a wordpress function but the page is so awful.
I found this: http://www.velvetblues.com/web-development-blog/custom-wordpress-comment-error-page/ and I kind of like the custom theme page but I am afraid it’s way over my simple coding abilities.
Do you have any alternative ideas/solutions/suggestions?
Thank you so much!!!
Havi
Hey havi,
This is the default wordpress comment form validation function. You could install a plugin like: https://de.wordpress.org/plugins/wp-ajaxify-comments/ to validate the comments on the same page.
If you just want to edit the error message you can try to add this code to the child theme functions.php file:
add_filter('avf_privacy_comment_checkbox_error_message', 'avia_privacy_comment_checkbox_error_message', 10, 1);
function avia_privacy_comment_checkbox_error_message($message)
{
$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
return "Error: You must agree to our privacy policy…. <a href='$url'>Back to previous page.</a>";
}
However I’m no sure if this code will work with the current theme version or if you must wait for the next theme update (because the filter “avf_privacy_comment_checkbox_error_message” might be missing in the current version).
Best regards,
Dude
Thank you!! Thank you!! Thank you!!! :)
I will check and let you know. I actually duplicated one of the sites and have it on a development environment so I can easily test everything and once I have my magic formula, I can deploy on all of my client sites (and mine) ;)
Hey!
Great, let us know if you need more help :)
Best regards,
Peter