Showing posts with label Add Captcha in Iq testimonial form. Show all posts
Showing posts with label Add Captcha in Iq testimonial form. Show all posts

Saturday, May 25, 2013

Add Captcha in IQ Testimonials( Wordpress Plugin ) Form

If you need to add captcha to stop spam on Wordpress IQ Testimonials Plugin Form (http://wordpress.org/plugins/iq-testimonials/) as captcha is not inbuilt in the form

First We need to Install and activate wordpress plugin Flexible Captha (http://wordpress.org/plugins/flexible-captcha/)

Once this Plugin is activated successfully .
Add below code in plugins/iq-testimonials/lib/iq-testimonials-form.php file
First to display Captcha filed above submit button in  the form add below code
$html .=  do_shortcode('[FC_captcha_fields]' ) ;

(just before this line of code almost line no.257)
 $html .= '<input id="submit" name="submit" type="submit" value="Submit" />
Now to put functionality of verifying captcha text Add below lines of code almost after line no 69

 global $FlexibleCaptcha;
 if (!$FlexibleCaptcha->check_captcha_val()) {
  $result['valid'] = false;
  $result['reason']['FC_captcha_input'] = 'The entered text did not match the captcha image.';
  $formerrorBits['capt'] = true;
        $formerrors[] = "<p class=\"iq-testimonials-error\">The entered text did not match the captcha image.</p>\n";   
     //$form_errors_present = true;
 }



Above code can be added before this existing  code in the file
if ((empty($email)) && ($form_email == 'true') && (empty($email_field))){
   $formerrorBits['email'] = true;
   $form_errors_present = true;
  }