Thursday, 22 August 2013

Wordpress Recaptcha registration validation

Wordpress Recaptcha registration validation

Guys could you please help me?, I'm stuck with the captcha. I can not
validate it ...
I do not want to use other plugins, I want to learn. Thank you. sorry for
my english
// test 1
//______________________________________________________//
//
add_action('register_form', 'myrecap', 1000);
function myrecap()
{
// display
require_once('recaptchalib.php');
$publickey = "mypublickey";
echo recaptcha_get_html($publickey, $error);
}
//______________________________________________________//
//______________________________________________________//
// valid???
add_action('register_post', 'validamyrecap', 10, 3);
function validamyrecap($login, $email, $errors)
{
require_once('recaptchalib.php');
$error = new WP_Error();
$privatekey = "myprivatekey";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if(($resp != $_POST['recaptcha_challenge_field']) && (!empty($resp)))
$errors->add('erroremyrecap',__('<strong>ERROR</strong>: The code you
entered was incorrect, please try again.'));
if(($resp != $_POST['recaptcha_response_field']) && (!empty($resp)))
$errors->add('erroremyrecap',__('<strong>ERROR</strong>:Wrong.'));
}
//______________________________________________________//

No comments:

Post a Comment