Sync an ACF map field with Ultimate


If editors use an Advanced Custom Fields Map field, sync its lat/lng (and address) into Progress Map Ultimate’s meta so markers stay aligned.

This is not a built-in Ultimate feature — it uses ACF’s acf/update_value hook plus Ultimate constants / marker save helpers.

/**
 * Synchronize an ACF Map field with Progress Map Ultimate.
 *
 * Replace your_ACF_map_field_name with your real ACF field name.
 */
function cspm_sync_ACF_map_field_with_PM( $value, $post_id, $field, $original ) {

	if ( empty( $field['name'] ) || 'your_ACF_map_field_name' !== $field['name'] ) {
		return $value;
	}

	if ( is_array( $value ) && isset( $value['lat'], $value['lng'] ) ) {

		update_post_meta( $post_id, CSPM_LATITUDE_FIELD, $value['lat'] );
		update_post_meta( $post_id, CSPM_LONGITUDE_FIELD, $value['lng'] );

		if ( isset( $value['address'] ) ) {
			update_post_meta( $post_id, CSPM_ADDRESS_FIELD, $value['address'] );
		}

		if ( class_exists( 'CSProgressMap' ) ) {
			$CSProgressMap = CSProgressMap::this();
			$CSProgressMap->cspm_save_marker_object( $post_id, get_post( $post_id ) );
		}
	}

	return $value;
}
add_filter( 'acf/update_value/name=your_ACF_map_field_name', 'cspm_sync_ACF_map_field_with_PM', 10, 4 );

Checklist

  1. Replace your_ACF_map_field_name exactly.
  2. Confirm Ultimate defines CSPM_LATITUDE_FIELD / CSPM_LONGITUDE_FIELD (loaded when the plugin is active).
  3. If you store coordinates only in custom keys, you can instead point Ultimate’s custom lat/lng fields at those keys — sync code may then be unnecessary.
  4. After bulk ACF imports, use Regenerate markers in Troubleshooting.

Reference

  • ACF docs for acf/update_value/name={$field_name}
Top