Black Friday & Cyber Monday
50% OFF All plans, upgrades & renewals
View offers

DEVELOPER

gmw_default_form_values filter

Customize GEO my WP runtime form values with gmw_default_form_values, including hook timing, callback arguments and a scoped terrain-map example.

3 min read · Updated December 1, 2026

The gmw_default_form_values filter changes a GEO my WP form's runtime values during setup. It applies to the form instance being rendered; it does not save changes to the stored form.

Hook and arguments

add_filter( 'gmw_default_form_values', 'your_callback', 50, 2 );

// Callback arguments:
// $form          Runtime form values (array).
// $form_instance The current GMW_Form_Core instance or subclass.

Return the complete $form array, with only your intended values changed. The second argument is the form object, not another settings array. A callback that uses only the first argument can register with one accepted argument; register two when your callback reads the instance. See WordPress's add_filter() reference for accepted-argument behavior.

When the filter runs

GMW_Form_Core::setup_defaults() first initializes runtime values and runs the component's default-value setup. It prepares page-load location information when needed and sets the form instance's identity and database fields before applying this filter.

After the general filter, GEO my WP applies its component-specific and prefix-specific default-value filters. A later filter can therefore override your change. Avoid changing identity fields such as ID, component, prefix or object_type here: some corresponding object properties have already been set.

The hook can run again for another form instance or request. Keep callbacks repeatable and avoid writes or external requests inside them. For permanent administrator configuration, use the form editor instead.

Example: use a terrain map for one form

This example changes only the runtime Google results-map type for form 1. Replace 1 with your form ID. It requires an enabled results map using Google Maps; changing this value does not enable a map or provide a terrain layer for Leaflet.

<?php
/**
 * Use Google's terrain map in GEO my WP form 1.
 *
 * @param array $form Runtime form values.
 * @param GMW_Form_Core $form_instance Current form instance.
 *
 * @return array
 */
function mysite_gmw_terrain_map( $form, $form_instance ) {
	if ( 1 !== (int) ( $form['ID'] ?? 0 ) ) {
		return $form;
	}

	$form['results_map']['map_type'] = 'TERRAIN';

	return $form;
}

add_filter( 'gmw_default_form_values', 'mysite_gmw_terrain_map', 50, 2 );

Place the callback and registration in your own plugin, a suitable code-snippet tool or a child theme's functions.php. Omit the opening PHP tag when pasting into an existing PHP file. Use a unique callback name and return the original array unchanged for forms outside your intended scope.

Test and troubleshoot

  1. Choose a test form with a working Google results map and replace the example ID.
  2. Open the page containing that form and confirm the map uses terrain.
  3. Check a second form to confirm its map settings remain unchanged.
  4. Disable the snippet and confirm the stored form setting takes effect again.

If the change is absent, check the actual form ID, callback registration, map provider and whether a later filter changes the same value. If the filter runs but its return value is missing or incomplete, other form behavior can break. Always preserve unrelated array keys.

Source and older documentation

The filter is in GMW_Form_Core::setup_defaults(), in includes/class-gmw-form-core.php. Older documentation points to GMW_Form::setup_defaults() in a different file; that source location is outdated. The older one-argument terrain example remains compatible, but it affects every matching form unless you add an ID check.

For administrator map settings, see Configure the results map. For taxonomy-specific arguments, use the taxonomy dropdown filter.