The filter gform_recaptcha_valid_hostnames allows developers to define the set of hostnames considered valid for reCAPTCHA verification. By default, Google returns a ‘hostname’ value in reCAPTCHA verification results.
Usage
add_filter( 'gform_recaptcha_valid_hostnames', 'your_function_name', 10, 1 );
Parameters
Parameter | Type | Description |
---|---|---|
$valid_hostnames | array | An indexed array of valid hostname strings. Defaults to an Array containing the WordPress home URL hostname |
Examples
Add additional hostnames for reCAPTCHA validation.
add_filter( 'gform_recaptcha_valid_hostnames', 'add_custom_recaptcha_hostnames', 10, 1 );
function add_custom_recaptcha_hostnames( $valid_hostnames ) {
$valid_hostnames[] = 'staging.example.com';
$valid_hostnames[] = 'dev.example.com';
return $valid_hostnames;
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
This filter is located in class-token-verifier.php.
Since
This filter was added in Gravity Forms reCAPTCHA 1.0.