Premiumpress offers great features out of the box, but the basic math capture field isn’t working.
A few weeks after launching the site it has been detected by spam bots.
I also tried to change the computations from “2+3” to “two + three”, but a few weeks later the spam was there again.
So I decided to solve the problem with reCaptcha one of the safest capture tools.
1. Get your reCaptcha API key
Create your API key here and remember your private and public key for the next steps.
2. Add reCaptha to your theme
Download the reCaptcha PHP library here
Extract files and upload recaptchalib.php to your theme path (e.g. wp-content/themes/realtorpress/)
3. remove JavaScript form check
open the file
/theme_reatorpress/_tpl_contact.php
and remove the lines where the form is checked in JavaScript:
if(code.value == ''){ ... }
4. display reCaptcha in the contact form
stay in the same file and find the
Empty the div container wrapping the inputs “code” and “code_value” and insert the following PHP code:
<?php require_once(TEMPLATEPATH.'/recaptchalib.php'); $publickey = "your_public_key"; echo recaptcha_get_html( "your_public_key"); ?>
just replace “your_public_key” with your real public key.
5. check the captcha after submission
now open
/tpl_contact.php
and find the line where the submitted code is checked (for me it was line 29):
if(isset($_GET['action']) && isset($_POST['form']['code']) ){
remove the code check here:
if(isset($_GET['action']) ){
find the next code check (line 36):
if(isset($_POST['form']['code']) && $_POST['form']['code'] == $_POST['form']['code_value']){...
and replace it by recaptchas verification:
require_once(TEMPLATEPATH.'/recaptchalib.php'); $privatekey = "your_private_key"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if( $resp->is_valid){...
add your private key here instead of the placeholder.
6. Customize reCaptcha (optional)
Here you find some additional infos to customize reCaptcha.
also add reCaptcha to article contact forms in premiumpress
repeat steps 4 and 5 but use the files
_single.php and header.php instead.
Premiumpress offers great features out of the box, but the basic math capture field isn’t working.
A few weeks after launching the site it has been detected by spam bots.
I also tried to change the computations from “2+3” to “two + three”, but a few weeks later the spam was there again.
So I decided to solve the problem with reCaptcha one of the safest capture tools.
1. Get your reCaptcha API key
Create your API key here and remember your private and public key for the next steps.
2. Add reCaptha to your theme
Download the reCaptcha PHP library here
Extract files and upload recaptchalib.php to your theme path (e.g. wp-content/themes/realtorpress/)
3. remove JavaScript form check
open the file
/theme_reatorpress/_tpl_contact.php
and remove the lines where the form is checked in JavaScript:
if(code.value == ''){ ... }
4. display reCaptcha in the contact form
stay in the same file and find the
Empty the div container wrapping the inputs “code” and “code_value” and insert the following PHP code:
<!--?php require_once(TEMPLATEPATH.'/recaptchalib.php'); $publickey = "your_public_key"; echo recaptcha_get_html( "your_public_key"); ?-->
just replace “your_public_key” with your real public key.
5. check the captcha after submission
now open
/tpl_contact.php
and find the line where the submitted code is checked (for me it was line 29):
if(isset($_GET['action']) && isset($_POST['form']['code']) ){
remove the code check here:
if(isset($_GET['action']) ){
find the next code check (line 36):
if(isset($_POST['form']['code']) && $_POST['form']['code'] == $_POST['form']['code_value']){...
and replace it by recaptchas verification:
require_once(TEMPLATEPATH.'/recaptchalib.php'); $privatekey = "your_private_key"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if( $resp->is_valid){...
add your private key here instead of the placeholder.
6. Customize reCaptcha (optional)
Here you find some additional infos to customize reCaptcha.
also add reCaptcha to article contact forms in premiumpress
repeat steps 4 and 5 but use the files
_single.php and header.php instead.