• I’ve using wp-recaptcha along with an ajax sidebar login tool (sb-login).

    On an AJAX postback, I’ll sometimes get an error in the error logs… cannot call add on a non-object.

    I tracked it down to validate_recaptcha_response($errors). Somehow, $errors is sometimes passed in as either false or null.

    I solved this by wrapping the two $errors->add() with a check:

    if(! is_wp_error($errors))
                	{
                		$errors = new WP_Error();
                	}
                    $errors->add('blank_captcha', $this->options['no_response_error']);
                    return $errors;

    and

    if(! is_wp_error($errors))
    					{
    						$errors = new WP_Error();
    					}
    
                        $errors->add('captcha_wrong', $this->options['incorrect_response_error']);

    It’s entirely possible something further up the chain is triggering the hook without $errors being set, but this might be a safe thing to do anyways. Hope you can import it into the next release.

    https://www.ads-software.com/plugins/wp-recaptcha/

  • The topic ‘Bug: $error is not an object’ is closed to new replies.