Advertisement
Guest User

Untitled

a guest
May 7th, 2010
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. // Check the recaptcha on WordPress MU
  2. function check_recaptcha_wpmu($result) {
  3.    global $_POST, $recaptcha_opt;
  4.    
  5.    // must make a check here, otherwise the wp-admin/user-new.php script will keep trying to call
  6.    // this function despite not having called do_action('signup_extra_fields'), so the recaptcha
  7.    // field was never shown. this way it won't validate if it's called in the admin interface
  8.    if (!is_admin()) {
  9.          // It's blogname in 2.6, blog_id prior to that
  10.       if (isset($_POST['blog_id']) || isset($_POST['blogname']))
  11.         return $result;
  12.  
  13.       // no text entered
  14.       if (empty($_POST['recaptcha_response_field']) || $_POST['recaptcha_response_field'] == '') {
  15.         $result['errors']->add('blank_captcha', $recaptcha_opt['error_blank']);
  16.         return $result;
  17.       }
  18.  
  19.       $response = recaptcha_check_answer($recaptcha_opt['privkey'],
  20.          $_SERVER['REMOTE_ADDR'],
  21.          $_POST['recaptcha_challenge_field'],
  22.          $_POST['recaptcha_response_field'] );
  23.  
  24.       // incorrect CAPTCHA
  25.       if (!$response->is_valid)
  26.         if ($response->error == 'incorrect-captcha-sol') {
  27.             $result['errors']->add('captcha_wrong', $recaptcha_opt['error_incorrect']);
  28.             echo "<div class=\"error\">". $recaptcha_opt['error_incorrect'] . "</div>";
  29.         }
  30.    }
  31.    
  32.    return $result;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement