Title: adding captcha to custom form
Last modified: May 4, 2020

---

# adding captcha to custom form

 *  Resolved [roryrory](https://wordpress.org/support/users/roryrory/)
 * (@roryrory)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-captcha-to-custom-form/)
 * Hello
    Thanks for that great plugin that i use in many websites. I would like
   to integrate the captcha of this plugin into my custom form. Here is how i create
   a new form in my plugin using shortcode. The process and validation is done by
   js/ajax. How can i add the do do_action( ‘anr_captcha_form_field’ ); or [anr_captcha]
   in that form? thanks
 * add_shortcode( ‘rorycontact’, ‘rorycontact_function’);
    public function rorycontact_function(){
   $formrory=”<form class=’formrorycontact’ id=’formrorycontact’>”; $formrory.=”
   <label for=’roryname’>Your name </label>”; $formrory.= ‘<input type=”text” class
   =”roryparam” value=”” />’; $formrory.= “<input type=’submit’ id=’submit’ value
   =’Submit’>”; $formrory.=”<form>”; return $formrory; }

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Shamim Hasan](https://wordpress.org/support/users/shamim51/)
 * (@shamim51)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-captcha-to-custom-form/#post-12782414)
 * You can add `$formrory.= anr_captcha_form_field();` just before submit button.
   When sending data in ajax, make sure to pass captcha response to your server.
   Then in server verify captcha using `anr_verify_captcha()` function.
 * Please also see [https://www.shamimsplugins.com/docs/advanced-nocaptcha-recaptcha/getting-started-advanced-nocaptcha-recaptcha/implement-in-custom-form/](https://www.shamimsplugins.com/docs/advanced-nocaptcha-recaptcha/getting-started-advanced-nocaptcha-recaptcha/implement-in-custom-form/)
 *  Thread Starter [roryrory](https://wordpress.org/support/users/roryrory/)
 * (@roryrory)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-captcha-to-custom-form/#post-12783671)
 * hello
    thanks I add the line. SO the form is like this now add_shortcode( ‘rorycontact’,‘
   rorycontact_function’); public function rorycontact_function() { $formrory=”<
   form class=’formrorycontact’ id=’formrorycontact’>”; $formrory.=”<label for=’
   roryname’>Your name </label>”; $formrory.= ‘<input type=”text” class=”roryparam”
   value=”” />’; $formrory.= anr_captcha_form_field(); $formrory.= “<input type=’
   submit’ id=’submit’ value=’Submit’>”; $formrory.=”</form>”; return $formrory;}
 * but nothing appears.
 * I checked in the source of the page and i see no extra code or js..
    can you 
   help me? What can i check to try to debug? thanks
 *  Thread Starter [roryrory](https://wordpress.org/support/users/roryrory/)
 * (@roryrory)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-captcha-to-custom-form/#post-12783774)
 * sorry it is working.
    I have checked the case “Hide Captcha for logged in users?”
   in admin…and i was login…
 *  Thread Starter [roryrory](https://wordpress.org/support/users/roryrory/)
 * (@roryrory)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-captcha-to-custom-form/#post-12784027)
 * Hello
    Can you confirm me that it is true. I get the response in .js and send
   it to ajax callback function using jQuery.ajax({ url :ajaxurl, data: { ‘action’:’
   rorycontactajax’, ‘captcha’:$.trim($(‘.g-recaptcha-response’).val()) }
 * then i verify in rorycontactajax using
    if ( anr_verify_captcha($_REQUEST[‘captcha’])){
   echo “captcha ok”; }else{ echo “captcha false”; }
 * thanks
 *  [Shamim Hasan](https://wordpress.org/support/users/shamim51/)
 * (@shamim51)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-captcha-to-custom-form/#post-12789859)
 * How are you sending other form data? If you are sending like `$("form").serialize()`
   then you will not need to include captcha value individually. In that case you
   can just use `anr_verify_captcha()`.
 * Your approach is also ok.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘adding captcha to custom form’ is closed to new replies.

 * ![](https://ps.w.org/advanced-nocaptcha-recaptcha/assets/icon-256x256.png?rev
   =2961544)
 * [CAPTCHA 4WP - Antispam CAPTCHA solution for WordPress](https://wordpress.org/plugins/advanced-nocaptcha-recaptcha/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-nocaptcha-recaptcha/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-nocaptcha-recaptcha/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-nocaptcha-recaptcha/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-nocaptcha-recaptcha/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-nocaptcha-recaptcha/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Shamim Hasan](https://wordpress.org/support/users/shamim51/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/adding-captcha-to-custom-form/#post-12789859)
 * Status: resolved