WordPress.org

Ready to get started?Download WordPress

Forums

how to validate reCAPTCHA in #commentform (2 posts)

  1. alexaung
    Member
    Posted 1 year ago #

    I have added reCAPTCHA into commentform and I can see the reCAPTCHA in comment form. But I have no idea where and how do I need to validate reCAPTCHA. I saw the function in my themes.
    // comment form validation
    jQuery("#commentform").validate({
    errorClass: "invalid",
    errorElement: "div",
    errorPlacement: function(error, element) {
    error.insertAfter(element);
    }
    });
    jQuery("#commentform").fadeIn();

    Thanks,
    Alex

  2. bcworkz
    Member
    Posted 1 year ago #

    You do not want to use client side script such as jQuery to verify CAPTCHAs, the spammer has control of the code and can easily sidestep the verification process. Verification must be server side.

    Assuming your form action still goes to wp-comments-post.php, you can verify the reCAPTCHA by adapting Google's suggested server side code to run from the WP action hook 'pre_comment_on_post'.

Topic Closed

This topic has been closed to new replies.

About this Topic