recaptcha check failed box
-
Hey guys,
great plug in. i have the recaptcha box in the sub submission form, i can see it, i can use it, but when i submit the listing i get a “are you a human? check failed”I put in the code in the documentation page, checked my keys in the google recaptcha website with the ones that i inserted inside the code.
I also put these same keys in the field editor that i have and have enabled the box.
I called my host to see if they are somehow blocking me but they are not, everything is good in their end.
the only part that i have change on the code is what is in bold due to the fact that i use field editor.
i dont know what else to do.
thanks in advance for your help
here is my snippet.
———————————
Job Manager Recaptcha
———————————— */define( ‘RECAPTCHA_SITE_KEY’, ‘i put in my keys here’ );
define( ‘RECAPTCHA_SECRET_KEY’, ‘i put in my keys here’ );
// Enqueue Google reCAPTCHA scripts
add_action( ‘wp_enqueue_scripts’, ‘recaptcha_scripts’ );
function recaptcha_scripts() {
wp_enqueue_script( ‘recaptcha’, ‘https://www.google.com/recaptcha/api.js’ );
}
// Add reCAPTCHA to the job submission form
add_action( ‘submit_job_form_job_fields_end’, ‘recaptcha_field’ );
function recaptcha_field() {
?>
<fieldset>
<label>Are you human?</label>
<div class=”field”>
<div class=”g-recaptcha” data-sitekey=”<?php echo RECAPTCHA_SITE_KEY; ?>”></div>
</div>
</fieldset>
<?php
}
// Validate
add_filter( ‘submit_job_form_validate_fields’, ‘validate_recaptcha_field’ );
function validate_recaptcha_field( $success ) {
$response = wp_remote_get( add_query_arg( array(
‘secret’ => RECAPTCHA_SECRET_KEY,
‘response’ => isset( $_POST[‘g-recaptcha-response’] ) ? $_POST[‘g-recaptcha-response’] : ”,
‘remoteip’ => isset( $_SERVER[‘HTTP_X_FORWARDED_FOR’] ) ? $_SERVER[‘HTTP_X_FORWARDED_FOR’] : $_SERVER[‘REMOTE_ADDR’]
), ‘https://www.google.com/recaptcha/api/siteverify’ ) );
if ( is_wp_error( $response ) || empty( $response[‘body’] ) || ! ( $json = json_decode( $response[‘body’] ) ) || ! $json->success ) {
return new WP_Error( ‘validation-error’, ‘”Are you human” check failed. Please try again.’ );
}
return $success;
}
/*————————————————————————————
Submit resume
————————————————————————————–*/
add_action( ‘submit_resume_form_resume_fields_end’, ‘recaptcha_field’ );
add_filter( ‘submit_resume_form_validate_fields’, ‘validate_recaptcha_field’ );/*————————————————————————————
Applications
————————————————————————————–*/
add_action( ‘job_application_form_fields_end’, ‘recaptcha_field’ );
add_filter( ‘application_form_validate_fields’, ‘validate_recaptcha_field’ );
- The topic ‘recaptcha check failed box’ is closed to new replies.