Support » Plugin: Custom Contact Forms » [Plugin: Custom Contact Forms] SPAM prevention with Recaptcha

  • Resolved aschmutt



    the current Captcha is not working.
    You write the captcha code in the session – and spambot can read the session data.

    This code can be used to include Recaptcha instead.
    You have to do these changes in custom-contact-forms-front.php:

    function getCaptchaCode($field_object, $form_id) {
    /*replace HTML Output in $out:
    $out = '<img width="96" height="24" alt="' . __('Captcha image for Custom Contact Forms plugin. You must type the numbers shown in the image', 'custom-contact-forms') . '" id="captcha-image" src="' . get_bloginfo('wpurl') . '/wp-content/plugins/custom-contact-forms/image.php?fid='.$form_id.'"'.$code_type.'>
    <div><label for="captcha'.$form_id.'">* '.$field_object->field_label.'</label> <input class="'.$field_object->field_class.' '.$tooltip_class.'" type="text" '.$instructions.' name="captcha" id="captcha'.$form_id.'" maxlength="20"'.$code_type.'></div>';
    return $out;*/
    $publickey = "your_key"; // you got this from
    $out = '<div><label for="captcha'.$form_id.'">* '.$field_object->field_label.'</label></div>';
    $out .= recaptcha_get_html($publickey);
    return $out;

    Then find elseif ($field->field_slug == 'captcha') {
    and replace the else code with recaptcha validation:

    elseif ($field->field_slug == 'captcha') {
    $privatekey = "your_private_key";
    $resp = recaptcha_check_answer ($privatekey,
    if (!$resp->is_valid) {
    if (empty($field->field_error))
    	$this->setFormError('captcha', __('You copied the number from the captcha field incorrectly.', 'custom-contact-forms'));
    else $this->setFormError('captcha', $field->field_error);

    Don’t forget to upload recaptchalib.php where require_once can find it.


Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Custom Contact Forms] SPAM prevention with Recaptcha’ is closed to new replies.