We are using Gravity Forms headlessly, and building out the forms based on the response from the REST API.
When submitting, I would expect to have to pass a recaptcha token to the submit endpoint so GF could reach out and validate with recaptcha, but I don’t see any documentation on how to do this.
Any help is appreciated.
Looks like when previewing in WP, GF is adding an invisible field like this:
<input id="input_9a528971b990a4074cb8e8a3afe5f25a" class="gfield_recaptcha_response" type="hidden" name="input_9a528971b990a4074cb8e8a3afe5f25a" value="">
But this is nowhere to be seen in the response from wp-json/gf/v2/forms/FORM_ID
, so I can’t submit the recaptcha value to the backend.
Am I missing something? v2 will work since it looks like it always expects the value to be sent to g-recaptcha-response
field.
Can do something like this in your functions.php to add the input name as a top level field to the form response.
add_filter('gform_form_post_get_meta', function ($form) {
if (class_exists( 'Gravity_Forms\Gravity_Forms_RECAPTCHA\GF_Field_RECAPTCHA' )) {
$field_RECAPTCHA = new Gravity_Forms\Gravity_Forms_RECAPTCHA\GF_Field_RECAPTCHA();
$id = $field_RECAPTCHA->get_input_name($form['id']);
$form['captcha_input_name'] = $id;
}
return $form;
});
system
(system)
Closed
April 24, 2025, 11:23am
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.