Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • @ninjew GoDaddy was sending the request to Google out from a different IP than the shared IP displayed in my cpanel… wish I’d actually bothered to check network traffic before debugging your code

    Thanks a million for the plugin can’t wait to have the first map live on the site.

    @geylang666 If you want the GMWP location to update after saving a post whose location was updated using the ACF map component in the admin, try this:

    function update_GMWP_location( $post_id ) {
        // Get newly saved values.
        $values = get_fields( $post_id );
    
        // Check the new value of a specific field.
        // replace 'location'  with your 'custom_field'
        $location = get_field('location', $post_id);
        if( $location ) {
            // make sure post ID exists.
    	if ( ! $post_id ) {
    		return;
        }
    	// verify updater function.
    	if ( function_exists( 'gmw_update_post_location' ) ) {
    		$coordinates = array(
    			"lat" => (float)$location["lat"],
    			"lng" => (float)$location["lng"]
    		);
    		gmw_update_post_location( $post_id, $coordinates );
    	}
        }
    }
    
    add_action('acf/save_post', 'update_GMWP_location');

    It fails for me at the same point as updating from the front end, so will probably work for you. Based on: https://www.advancedcustomfields.com/resources/acf-save_post/

    • This reply was modified 4 years, 7 months ago by creatino.

    @geylang666 Glad it worked for you, still not working on my side.

    You can edit location in admin screens by activating GMWP widget on the correct pages.

    Admin side menu > Geo My WP > Settings > Post locator > Post Types

    Select the post types where you would like to enable geotagging. GEO my WP Location section will be added to the “Edit Post” page of the selected post types.

    Hey @ninjew I followed your basic approach but using coordinates instead of address, and wrote the following:

    function gmw_update_location_via_wpuf($post_id) {
    	// make sure post ID exists.
    	if ( ! $post_id ) {
    		return;
        }
    
    	// verify updater function.
    	if ( function_exists( 'gmw_update_post_location' ) ) {
    		// change meta_field_name to the custom field of the address field.
    	    $locationMeta = get_post_meta( $post_id, 'location', true );
    		$coordinates = array(
    			"lat" => (float)$locationMeta["lat"],
    			"lng" => (float)$locationMeta["lng"]
    		);
    		//run geocoder function
    		gmw_update_post_location( $post_id, $coordinates );
    	}
    }
    
    //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_edit_post_after_update', 'gmw_update_location_via_wpuf', 10, 1 );

    Everything is firing fine, but the location doesn’t update in . I started debugging to follow why, and got as far as:

    [21-Apr-2020 09:22:06 UTC] 1276
    [21-Apr-2020 09:22:06 UTC] GMW – Posting
    [21-Apr-2020 09:22:06 UTC] GMW – Defaulted to post nameasdasd
    [21-Apr-2020 09:22:06 UTC] Updating location
    [21-Apr-2020 09:22:06 UTC] GMW – gmw_update_location
    [21-Apr-2020 09:22:06 UTC] GMW – gmw_update_location – array recognised
    [21-Apr-2020 09:22:06 UTC] GMW – gmw_update_location – array lat and lng found
    [21-Apr-2020 09:22:06 UTC] GMW – $geo_addressArray
    (
    [lat] => 40.71791458474
    [lng] => -73.962794899278
    )
    [21-Apr-2020 09:22:06 UTC] GMW – gmw_update_location – Geocoding failed

    Before I start debugging in class-gmw-geocoder.php, any stupid mistakes I may be making in the encoding of the lat and lng? I’m a total newbie to PHP so probably missing something stupid.

    BTW, regarding the hooks mentioned in your tutorial (thanks!):
    based on the info at https://wedevs.com/docs/wp-user-frontend-pro/developer-docs/actions/wpuf_edit_post_after_update/ I think wpuf_add_post_after_updated should be wpuf_edit_post_after_update

    <EXPLODE> Muchas gracias amigos, much appreciated. </EXPLODE>

    Hi Gey, I’ve run into the same issue. I’ve seen that under the Import/Export tab of the GMWP settings, you can map post fields to GMWP LAT and LON fields to import the data when desired, on-demand. I’d obviously prefer a direct way to connect these fields, but don’t see a way of doing that via plugin settings alone.

    I’m also not sure how WPUF stores location information when a post is submitted from the front end. I see the following data in the AJAX submit calls:
    “location: Carrer del Llatzeret, 11, 08005 Barcelona, Spain || 41.4029902 || 2.2014224” – but that data doesn’t seem to be stored on the post, also I wouldn’t know how to extract LAT and LON values from the data. GWMP doesn’t recognise any location information on the post.

Viewing 6 replies - 1 through 6 (of 6 total)