Support » Plugin: WP Geo » [Plugin: WP Geo] Front end use with gravity forms

  • Is there a way to use this plugin on the front end through gravity forms? I found this code on the gravity forms forum and was left without the ability to search for a location.

    If there is a way to make something like this work, then I would be willing to pay for it.

    add_filter("gform_pre_render", "gravityforms_wpgeo_mashup");
    function gravityforms_wpgeo_mashup($form) {
        //REPLACE 1 with your actual form id
        $my_geo_form = 1;
        if($form["id"] !=$my_geo_form)
        // find IDs of latitude&longitude custom fields
        foreach($form["fields"] as &$field){
                if($field["postCustomFieldName"]=="_wp_geo_longitude") $field_lng = $field["id"];
                if($field["postCustomFieldName"]=="_wp_geo_latitude") $field_lat = $field["id"];
        // show map only if latitude&longitude custom fields exist
        if($field_lng && $field_lat ) :
            // load "WP Geo" plugin
            require_once( WP_PLUGIN_DIR . '/wp-geo/wp-geo.php' );
            global $wpgeo;
            $wpgeo = new WPGeo();
            $zoom = 2;
            $map = $wpgeo->mapScriptsInit( 20, 0,$zoom, true, false );
            $map .='
                <input type="hidden" name="wpgeo_map_settings_zoom" id="wpgeo_map_settings_zoom" value="" />
                <input type="hidden" name="wpgeo_map_settings_type" id="wpgeo_map_settings_type" value="" />
                <input type="hidden" name="wpgeo_map_settings_centre" id="wpgeo_map_settings_centre" value="" />
                <input name="wp_geo_latitude" type="hidden" size="25" id="wp_geo_latitude" value="" />
                <input name="wp_geo_longitude" type="hidden" size="25" id="wp_geo_longitude" value="" />
                <script type="text/javascript">
                    jQuery(document).ready(function() {';
                        $map .='var my_geo_form= '.$my_geo_form.';';
                        $map .='var field_lng= '.$field_lng.';';
                        $map .='var field_lat= '.$field_lat.';';
                        $map .='
                        jQuery("#wp_geo_map").click(function(e) {
                <div id="wp_geo_map" style="width:auto; height:400px"></div>';
            // find ID of section with cssClass "wpgeo" and put the map into description
            foreach($form["fields"] as &$field){
        return $form;

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WP Geo] Front end use with gravity forms’ is closed to new replies.