GEO my WP integration when creating posts from a front-end form

Hi there!
I would like to populate the post type locations into GEO my WP custom table in database. With GEO my WP by default it is only possible to assign location to a post using GMW Location section in the back-end. However, I would like to save post's location into GEO my WP database table when creating posts/products from the front-end form.
This is my form:
<input type="text" name="l" id="" value="" />
So after submiting the post in the frontend, the product location will be created/updated.

This post will help you to understand what I'm trying to do.
http://docs.geomywp.com/gmw_pt_update_location/

The first screen shot is the backend product page location section I want to populate when users fulfill the form in the front end, the second one is my frontend form.

Thank you.

Marc

  • Predrag Dubajic
    • Support

    Hey Marc,

    Hope you're doing well today :slight_smile:

    Besides the input field did you add the function to your theme's function.php file as shown in example from link you pasted above?

    Please provide as many info about what you have done so far so we know where to look from :slight_smile:

    Thank you,
    Predrag

  • MarK
    • Flash Drive

    Hi Predrag,

    Thank you for your reply.

    Yes I did write the script in my theme's function.php file , but I don't how to 'customize" this script to make it work.

    I don't know which values I have to put in name="" id="" value="" to link it with the geo my wp database and the script. I've been during the 6 past hours trying to make it.

    <input type="text" name="" id="" value="" />

    I tried this

    <div class="field-wrap">
    <input type="text" name="location" id="location" value="<?php echo $location ?>" />
    </div>

    with

    $location = get_post_meta( $post_id, 'location', true );
    
    	//include geocoder file
    	include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );
    
    	if ( function_exists( 'gmw_pt_update_location' ) ) {
    		//setup geocoder args
    		$args = array(
    				'post_id'         => $post_id,
    				'post_type'       => get_post_type( $post_id ),
    				'post_title'      => get_the_title( $post_id ),
    				'address'         => $location
    		);
    		//run geocoder function
    		gmw_pt_update_location( $args );
    	}
    }
    //update data of new post
    add_action('wpuf_add_post_after_insert', 'gmw_update_location_via_wpuf', 10, 1 );
    //update data when post updated
    add_action('wpuf_add_post_after_updated', 'gmw_update_location_via_wpuf', 10, 1 );

    Thank you Marc

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.