I have a template for contact us page which includes a small form with few text fields. I want to add Recaptcha to avoid spams. I already use WP-recaptch plugin which only works for default Registration and comment form. If follow these instructions from recaptcha docs, I get error the same class instance is being declared twice. Thats becoz recaptchalib.php is used by WP-repatcha already. This error will occur even if I use Contact 7 form plugin with recaptcha as every such plugin going to redeclare the same class.
I include recaptchalib.php from WP_captcha plugin to my template file and it works well to show Recaptcha box, but it doesnt works at validation part - below code doesnt work:
require_once ( WP_PLUGIN_DIR . '/wp-recaptcha/recaptchalib.php');
$privatekey = "my key";
if (empty($_POST['recaptcha_response_field']) || $_POST['recaptcha_response_field'] == '') {
$captchaErr = 'Please Enter recaptcha text';
$hasError = true;
}else{
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly - show error
Please can someone suggest a solution?