Skip to content

Commit

Permalink
gpaa-restrict-country-by-field.php: Added new snippet.
Browse files Browse the repository at this point in the history
  • Loading branch information
spivurno authored Nov 28, 2023
1 parent e7c7a56 commit ac194de
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions gp-address-autocomplete/gpaa-restrict-country-by-field.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Gravity Perks // Address Autocomplete // Restrict Country by Field
* https://gravitywiz.com/documentation/gravity-forms-address-autocomplete/
*
* Restrict autocomplete results to a specific country (or countries) for a specific field.
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-custom-javascript/
*
* 2. Follow the inline instructions to configure this for your specific field.
*/
gform.addFilter( 'gpaa_autocomplete_options', function( autocompleteOptions, gpaa, formId, fieldId ) {
// Update "1" to your Address field ID.
if ( formId != GFFORMID || fieldId != 1 ) {
return autocompleteOptions;
}
if ( typeof autocompleteOptions.componentRestrictions !== 'object' ) {
autocompleteOptions.componentRestrictions = {};
}
// Update "DE" to the country to which you would like to restrict results.
autocompleteOptions.componentRestrictions.country = [ 'DE' ];
return autocompleteOptions;
} );

0 comments on commit ac194de

Please sign in to comment.