simple reCaptcha for Buddypress /register page
-
After some fiddling, copying, more fiddling, I think I’ve got a working reCaptcha code. As it is, you just put this code in your theme’s functions.php file (I just made a child theme of the bp-default), edit the code to add a link to the recaptchalib.php file (get it here: http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest ) and your public and private keys, and you’re good to go. Here’s the code:
<?php
require_once(‘/path/to/recaptchalib.php’);function bpn_add_reg_field() {
global $bp;
$publickey = “”;
echo recaptcha_get_html($publickey);
if ( !empty( $bp->signup->errors)) {
echo $bp->signup->errors;
}
}function bpn_check_reg_recaptcha($errors)
{
global $bp;
$private_key = “”;if (function_exists(‘recaptcha_check_answer’))
{
$response = recaptcha_check_answer($private_key, $_SERVER[“REMOTE_ADDR”], $_POST[“recaptcha_challenge_field”], $_POST[“recaptcha_response_field”]);if (!$response->is_valid)
{
$bp->signup->errors = __( ‘ERROR: Captcha response is either empty or incorrect.’,’buddypress’);
}
}return ;
}add_action( ‘bp_before_registration_submit_buttons’, ‘bpn_add_reg_field’ );
add_action(‘bp_signup_validate’, ‘bpn_check_reg_recaptcha’ );?>
- The topic ‘simple reCaptcha for Buddypress /register page’ is closed to new replies.