Closed andyburnsco closed 4 years ago
Would you mind moving over to V3 reCAPTCHA, this should resolve the issue.
Tested V3 and it results in the same behavior.
The captcha wasn't entered correctly. Reset.
The form does not get submitted. I believe formerly the data would be entered.
@andyburnsco , would you feel comfortable trying my PR (https://github.com/andrewlimaza/caldera-forms-anti-spam/pull/21)? I believe it fixes the issue that you're experiencing.
Hi @ecaron ! I'm having identical problem with both v2 and v3. I downloaded "test" branch instead of "master", but the same issue persist. Should I try something else? Regards
@dupovacemir If you try the master branch of https://github.com/coffeeandbagels/caldera-forms-anti-spam, does it work for you?
I tried v2 and v3 with mail validation from that branch.
V3 didn't passed submission because of javascript error:
V2 passed submission, but still got the same as the current issue.
Okay, so I think I bypassed this error. Basically after the email validates, caldera tries to submit form again, but fails after recaptcha is not validated because no input occurred. So I thought that we could check GET parameters for email validation which are: "validatetoken" and "cf_tp". For exaple this is validation url: https://localhost:3000/?validatetoken=856f193a500e566b48533f16006ab05fea07be93&cf_tp=_cf_process_5fed17bb6f354_
If those parameters are set, we can just disable captcha and the form submits normally. I understand that this is probably amateur solution, I apologize, but it worked. :D
Below is the code: `/**
@return WP_Error|boolean */ public function handler( $value, $field, $form ){
if(isset($_GET['validatetoken']) && isset($_GET['cf_tp'])) {
return true;
} else {
/**
* Check if this is V3, then we grab the dynamically generated field value
*/
if (!empty($field['config']['recapv']) && $field['config']['recapv'] === 1 ) {
if(!empty($_POST['cf-recapv-token'])){
$_POST[ 'g-recaptcha-response' ] = $_POST['cf-recapv-token'];
}
}
if ( ! isset( $_POST[ 'g-recaptcha-response' ] ) || empty( $_POST[ 'g-recaptcha-response' ] ) ) {
return new WP_Error( 'error' );
}
$args = array(
'secret' => $field[ 'config' ][ 'private_key' ],
'response' => sanitize_text_field( $_POST[ 'g-recaptcha-response' ] )
);
$request = wp_remote_get( add_query_arg( $args, 'https://www.google.com/recaptcha/api/siteverify' ) );
$result = json_decode( wp_remote_retrieve_body( $request ) );
if ( empty( $result->success ) ) {
return new WP_Error( 'error',
__( "The captcha wasn't entered correctly.", 'cf-anti-spam' ) . ' <a href="#" class="reset_' . sanitize_text_field( $_POST[ $field[ 'ID' ] ] ) . '">' . __( 'Reset', 'cf-anti-spam' ) . '<a>.'
);
}
return true;
}
}`
Do You Need Immediate Help?
Is This A Feature Request?
What Version Of Caldera Forms, WordPress and PHP Are You Using?
Does Your Issue Persist When You Disable All Other Plugins and Switch To The Default Theme?
Yes, tested with 2019 Theme. Active: Caldera Forms 1.8.4, Caldera Forms Anti Spam 0.1.2, Verify Email for Caldera Forms 1.2.0.
What Is The Unexpected Behaviour?
Please explain what you did
what you expected to happen
and what happened instead.
It takes you back to the form again, and there's a message saying "The captcha wasn't entered correctly. Reset." Reset is a link that doesn't do anything. The user is confused by this and has no way of knowing if they successfully submitted the form.
No success message
No email notification sent
Apparently the recaptcha breaks the rest of these aforementioned steps that should occur.
What PHP Errors Have You Logged While Reproducing This Bug?
What JavaScript Errors Have You Seen While Reproducing This Bug?