• Hi there, plugin works really good on contact form 7 but i would like to know the way to restrict places to an specific country.
    when entering address/location Google Places display places and address from everywhere.
    Im using plugin with locations from 1 country.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I, too, would like to know how to do this.

    Thread Starter smartstartaus3081

    (@smartstartaus3081)

    Hey Frank

    after lots of searching online, i have found and added an extra piece of code to backend file.

    On file manager (cpanel) go to plugin folder
    public_html/wp-content/plugins/autocomplete-location-field-contact-form-7/includes

    open or edit php file GWAA_Backend.php

    add extra code after autocomplete.inputId = acInputs[i].id;

    extra code:

    // Set initial restriction to the greater list of countries.
    // [START maps_places_autocomplete_countries_multiple]
    autocomplete.setComponentRestrictions({country: [“au”],});

    you can select your country based on google country codes.

    it worked for my site.

    Thank you very much! Would this work for restricting states too?

    I actually looked and I don’t see that line of code in the file. Weird!

    So, I actually found it. But this doesn’t seem to be working. Am I missing something?

    var autocomplete = new google.maps.places.Autocomplete(acInputs[i]);
    								autocomplete.inputId = acInputs[i].id;
    // Set initial restriction to the greater list of countries.
    // [START maps_places_autocomplete_countries_multiple]
    autocomplete.setComponentRestrictions({country: [“us”],});
    
    								google.maps.event.addListener(autocomplete, 'place_changed', function () {
    									
    								});
    							}

    @smartstartaus3081 does that look correct?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Country Restriction’ is closed to new replies.