Geolocation by specific country

Hi all, I’m have the GeoLocation addon and working via Google Places API, I’m trying to limit address to South Africa only.

  1. I’m Using Garvity forms Version 2.9.9
  2. Geolocation by Gravity Forms - 1.5.0
  3. Divi Builder

I have inserted the following code into the functions.php file right at the bottom. But it still is not working. Any pointer or advice will be appreciated.

function limit_autocomplete_to_south_africa( $options, $form_id ) {
if ( $form_id == 8 ) {
$options[‘componentRestrictions’] = array( ‘country’ => ‘za’ );
}
return $options;
}
add_filter( ‘gform_geolocation_place_autocomplete_options’, ‘limit_autocomplete_to_south_africa’, 10, 2 );

gform_geolocation_place_autocomplete_options is a JavaScript filter, not a PHP filter. See the following page of the documentation for usage examples:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.