A professional WordPress plugin that adds address autocomplete functionality with map support to popular form builders.
- Multiple Provider Support: Choose between OpenStreetMap (free, no API key) or Google Maps
- Form Builder Integration: Works seamlessly with Contact Form 7, WPForms, and Gravity Forms
- Map Display: Show selected addresses on interactive maps with markers or route display
- Smart Caching: Reduces API calls and improves performance
- Fully Translatable: Includes English and French translations out of the box
- Extensible Architecture: Easy to add new providers and form integrations
- Custom Hooks: Extensive hooks for developers to customize functionality
- WordPress 5.8 or higher
- PHP 7.4 or higher
- At least one of the supported form plugins:
- Contact Form 7
- WPForms (Lite or Pro)
- Gravity Forms
- Upload the
wordpress-address-autocompletefolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Go to Settings > Address Autocomplete to configure your provider
- If using Google Maps, add your API key in the settings
- Navigate to Settings > Address Autocomplete
- Choose your preferred map provider:
- OpenStreetMap (recommended for most users - free, no API key required)
- Google Maps (requires API key)
- If using Google Maps:
- Get an API key from Google Cloud Console
- Enable the following APIs:
- Places API
- Maps JavaScript API
- Geocoding API
- Enter the API key in the settings
- Enable Cache: Toggle to enable/disable response caching
- Cache Duration: Set how long to cache API responses (default: 24 hours)
- Edit a Contact Form 7 form
- Click the Address Autocomplete tag button
- Configure the field (name, required, placeholder, etc.)
- Click Insert Tag
To add a map:
- Click the Address Map tag button
- Specify which address fields to display (comma-separated field names)
- Choose display mode (Markers or Route)
- Set map height
- Click Insert Tag
Example form code:
[address_autocomplete* address-1 placeholder "Enter your address"]
[address_autocomplete address-2 placeholder "Enter destination"]
[address_map map-1 fields:address-1,address-2 mode:route height:500px]
- Edit a WPForms form
- In the form builder, look for Address Autocomplete in the Fancy Fields section
- Drag and drop the field into your form
- Configure field settings (label, description, required, placeholder)
To add a map:
- Drag the Address Map field into your form
- In field settings:
- Address Fields to Display: Enter comma-separated field IDs (e.g., 1,2,3)
- Display Mode: Choose Markers or Route
- Map Height: Set desired height (e.g., 400px)
- Edit a Gravity Forms form
- Click Add Fields and look for Address Autocomplete in Advanced Fields
- Drag the field into your form
- Configure field settings in the right panel
To add a map:
- Add the Address Map field from Advanced Fields
- Configure settings:
- Address Fields to Display: Enter comma-separated field IDs (e.g., 1,2,3)
- Display Mode: Choose Markers or Route
- Map Height: Set desired height
Shows individual markers for each address on the map. Users can click markers to see address details.
Displays all addresses connected by a route line, perfect for showing directions or travel paths.
wpaa_initialized
Fires after the plugin is fully initialized.
add_action( 'wpaa_initialized', function() {
// Your code here
});wpaa_activated
Fires when the plugin is activated.
wpaa_deactivated
Fires when the plugin is deactivated.
wpaa_frontend_assets_enqueued
Fires after frontend assets are enqueued.
wpaa_admin_assets_enqueued
Fires after admin assets are enqueued.
wpaa_cache_cleared
Fires after cache is cleared.
add_action( 'wpaa_cache_cleared', function( $count ) {
// $count = number of deleted cache entries
}, 10, 1 );wpaa_provider_error
Fires when a provider error is logged.
add_action( 'wpaa_provider_error', function( $message, $context, $provider_id ) {
// Log or handle errors
}, 10, 3 );wpaa_cache_enabled
Filter whether cache is enabled.
add_filter( 'wpaa_cache_enabled', function( $enabled ) {
return true; // or false
});wpaa_cache_duration
Filter cache duration in seconds.
add_filter( 'wpaa_cache_duration', function( $duration ) {
return 3600; // 1 hour
});wpaa_search_query
Filter search query before processing.
add_filter( 'wpaa_search_query', function( $query ) {
return trim( $query );
});wpaa_search_results
Filter search results before sending to frontend.
add_filter( 'wpaa_search_results', function( $results, $query ) {
// Modify results
return $results;
}, 10, 2 );wpaa_place_details
Filter place details before sending to frontend.
add_filter( 'wpaa_place_details', function( $details, $place_id ) {
// Modify details
return $details;
}, 10, 2 );- Create a new provider class extending
WPAA_Provider_Abstract:
class WPAA_Provider_Custom extends WPAA_Provider_Abstract {
public function __construct() {
$this->id = 'custom-provider';
$this->name = __( 'Custom Provider', 'your-textdomain' );
$this->requires_api_key = true; // or false
}
public function search( $query ) {
// Implement search logic
}
public function get_place_details( $place_id ) {
// Implement place details logic
}
public function validate() {
// Implement validation logic
}
public function get_map_script_url() {
// Return map script URL
}
}- Register your provider:
add_filter( 'wpaa_available_providers', function( $providers ) {
$providers[] = 'custom-provider';
return $providers;
});
add_filter( 'wpaa_provider_class_map', function( $class_map ) {
$class_map['custom-provider'] = 'WPAA_Provider_Custom';
return $class_map;
});- Create a new integration class extending
WPAA_Form_Integration_Abstract:
class WPAA_Custom_Form extends WPAA_Form_Integration_Abstract {
private function __construct() {
$this->id = 'custom-form';
$this->name = 'Custom Form';
$this->plugin_file = 'custom-form/custom-form.php';
$this->init();
}
public function init() {
if ( ! $this->is_plugin_active() ) {
return;
}
// Add hooks
}
protected function register_field_type() {
// Register your field type
}
public function render_field( $field, $args = array() ) {
// Render field HTML
}
}- Initialize your integration in the main plugin file.
The plugin is fully translatable and includes:
- English (default)
- French
To add a new language:
- Copy
languages/wp-address-autocomplete.pot - Translate using Poedit or similar tool
- Save as
wp-address-autocomplete-{locale}.poand generate.mofile - Place in the
languages/folder
Run PHPUnit tests:
cd /path/to/plugin
composer install
./vendor/bin/phpunitThis plugin is licensed under the GPL v2 or later.
NDNCI
- Website: www.ndnci.com
Contributions are welcome! Please feel free to submit a Pull Request.
For support, please visit www.ndnci.com or open an issue on GitHub.
- Initial release
- Support for OpenStreetMap and Google Maps
- Integration with Contact Form 7, WPForms, and Gravity Forms
- Map display with markers and route modes
- Caching system
- English and French translations
- Extensive developer hooks
- Support for additional form builders (Elementor Forms, Formidable Forms)
- More map providers (Mapbox, HERE Maps)
- Geolocation support
- Address validation
- Custom styling options for maps
- Bulk geocoding for existing data
- Smart caching reduces API calls
- Debounced search input (500ms delay)
- Lazy loading of map libraries
- Minified assets for production
- Nonce verification on all AJAX requests
- Input sanitization and validation
- Secure API key storage
- No sensitive data logged in production
- Reduces API costs and improves performance
- Configurable cache duration
- Automatic cache invalidation
- One-click cache clearing from admin
- Interactive markers with info windows
- Route display between multiple addresses
- Auto-fit bounds to show all markers
- Responsive design
- Support for custom map heights
- Respects each form builder's UI/UX
- Follows WordPress coding standards
- Compatible with form validation
- Works with conditional logic
- AJAX-powered for smooth UX
- Use OpenStreetMap for development - No API key required, perfect for testing
- Enable caching in production - Significantly reduces API costs
- Set appropriate cache duration - Balance between freshness and performance
- Test API connections - Use the built-in connection tester in settings
- Monitor API usage - Keep track of your API quotas if using Google Maps
Autocomplete not working?
- Check that JavaScript is enabled
- Verify provider settings are correct
- Test the provider connection in settings
- Check browser console for errors
Map not displaying?
- Ensure map script is loading correctly
- Verify field IDs are correct in map settings
- Check that addresses are selected before map loads
- Try clearing cache
Google Maps API errors?
- Verify API key is correct
- Check that required APIs are enabled in Google Cloud Console
- Ensure billing is set up (Google requires it even for free tier)
- Check API key restrictions