Support » Plugin: Advanced noCaptcha & invisible Captcha (v2 & v3) » How to Validate the Recaptcha on Custom Forms

  • Hi Shamim,
    The recaptcha v3 is displaying fine on our form page although it’s not validating and spam submissions are getting through. Assuming the validation isn’t occurring with the plugin and just adding the shortcode to the form.

    Where do we place the anr_verify_captcha() script to validate the form? Is there generic php script for it to reside in the functions.php for the child theme?

    Thanks!
    ED

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Shamim Hasan

    (@shamim51)

    You can follow https://www.shamimsplugins.com/docs/advanced-nocaptcha-recaptcha/getting-started-advanced-nocaptcha-recaptcha/implement-in-custom-form/

    That function need to be added in form process function which is not possible to know without seeing that form process code.

    Hello Shamim,
    Can you please make a short video on how to add to custom PHP code?
    Currently, I can show the captcha, but I’m not sure how to verify.

    Thanks

    Hi Shamim, i am trying to do the same thing, and your linked page above helped. Would this be correct?

    <form action="somewhere.php" method="POST">
    
        <input id="first_name" maxlength="40" name="first_name" size="20" type="text" required="">
    
        <?php do_action('anr_captcha_form_field');?>
        
        <?php
    
            if ( anr_verify_captcha() ) {
                // Answer is right
                // process form
            } else {
                // Answer is wrong
                // Show error or take other necessary action
                // Do not process form
                event.preventDefault();
                alert("Please check the recaptcha");
            }
            ?>
        
        <input type="submit" name="submit">
    </form>

    So, is anr_verify_captcha() in a good place or does it even matter?
    Thanks!

    • This reply was modified 1 year, 3 months ago by benjaminblue.
    • This reply was modified 1 year, 3 months ago by benjaminblue. Reason: fixed error

    accidental second message.

    • This reply was modified 1 year, 3 months ago by benjaminblue.
    • This reply was modified 1 year, 3 months ago by benjaminblue.
    Plugin Author Shamim Hasan

    (@shamim51)

    anr_verify_captcha() will be in your validate function. in your case in somewhere.php

    Suppose when someone submit this form you send an email to admin with this form content. anr_verify_captcha() will be there before email sent. So if this function return false then you will not send email to admin. Instead you will show error to that user so that they get another chance to solve captcha.

    Thank you for the quick reply!

    I totally understand, and my issue is, I am working on a form previously coded by another dev, and it posts to somewhere else – my somewhere.php is actually an external .asp that I cannot change nor do I have access to.

    Any ideas on somehow working around that?

    Plugin Author Shamim Hasan

    (@shamim51)

    In that case i believe it will be better for you to hire any developer. They can investigate more closely and write code for you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to Validate the Recaptcha on Custom Forms’ is closed to new replies.