- This topic has 28 replies, 9 voices, and was last updated 3 years, 7 months ago by
anticosti.
-
AuthorPosts
-
June 26, 2014 at 1:21 pm #33554
Eyal Fitoussi
Member@Tom,
Take a look at this post. It will show you how to add locations to GEO my WP with Formidable Pro.
I am not sure about the lat/lng fields with Formidable pro yet but I will take a look at it later.@lily,
You will need to use a certain plugin or theme that posts from the front end. IF you do let me know which one.June 26, 2014 at 7:59 pm #33553Tom Poon
MemberCheers Eyal for looking into it!
For the lat/long, is it possible to change the “address” field with the shortcodes for the lat/long?
For example this line;
‘address’ => $_POST[‘item_meta’][102],[103]
Because if you type in lat,long for an address, it still takes you to the right place…
It’s also possible to just combine the lat/long fields into 1 hidden field in formidable pro.
Anyway I tried it with just the single address field, but I can’t seem to get it working? How do I verify that something has been added to Geo My WP’s database? I’ve just been trying to search it with the geo my wp search form
Maybe I’m missing a step… all I did was paste that code into my functions, edited the formidable field and then made a new post, is there something I’m missing?Thanks
June 26, 2014 at 8:13 pm #33552Eyal Fitoussi
MemberHey Tom,
I haven’t tried using lat/lng instead of an address but it might work if you use “latitude,longitude” instead of the address field.To check if the the script is working you first need to go to the admin dashboard->GEO my WP->Settings -> Post Types tab. in the Post Types feature make sure that the checkbox of the post type that you are using is checked.
Then after creating a new post using Formidable Pro plugin go to the “Edit post” page and see if the location data is in the “GWM Location” section.June 27, 2014 at 12:02 am #33551Tom Poon
MemberWohoo finally got it sorted, been faffing about with all sorts of trial and error until I got something working with lat/long 😀
I found out the initial reason it wasn’t working for me was because the form id was wrong, doh 🙁 But after that, I tried to get long/lat to work…Here’s how I did it (for others wanting to do the same):
1) Install Formidable Geocoder;
2) Create a hidden field in the form that will use that geocoder, this will be used to combine the lat/long into 1 field
3) Add this action to your functions.php;
12345678add_action('frm_validate_entry', 'combine_lat_long', 20, 2); //make sure the order is higher then 10 to prevent overwritingfunction combine_lat_long($errors, $values){if(isset($values['item_meta']) and isset($values['item_meta'][109])){ //change 109 to a field ID required in the field title$title = $values['item_meta'][109] .','. $values['item_meta'][108]; //combine them here however you'd like. The numbers are the field IDs$_POST['item_meta'][243] = $_POST['frm_wp_post']['243=lat_long'] = $title; //change both 243s to the ID of the hidden field}return $errors;}4) Do the stuff on this post; http://tempform.wpengine.com/documentation/geo-wp-formiable-pro-integration/
And that’s all 🙂 Thanks so much Eyal, time to buy the Geo My WP global mashup addon! This was literally the only thing I was waiting for to get my site working how I want it to, I really didn’t wanna buy gravity forms because I’m so happy with formidable pro!
Edit: Oh no, it’s *slightly” off… the inputted lat/long is offset a bit, not enough to be in the completely wrong place, but if I input;
53.838994,-2.189672, it appears correctly on the “type an address to autocomplete” field but in the geo My WP lat/long fields it says
53.839840,-2.189690 …I think it’s doing that because it’s trying to get the closest address with a door number, but I don’t want to do that 🙁 The things I’m marking on my maps are parks and fields so it’d be best if it didn’t automatically look for the closest address. Can this behaviour be changed?
June 27, 2014 at 12:26 am #33550Tom Poon
MemberThe edit button has disappeared on my previous post… I guess I can’t edit a post twice?
Anyway, another problem I just discovered.
When I edit a post created by formidable to change the location, it doesn’t get updated. Is there a way to modify your action to include editing a post instead of just working for new posts?June 27, 2014 at 12:53 am #33549Alvin Bond
Member1) Use a front-end post submission plugin ( there are free plugins for that ) to create posts from the from-end. When you do so I can provide you with a function that will save the address entered when submitting a post into GEO my WP tables.
Hello Eyal,
Thank you for creating such a great plugin.
I am using WP User Frontend, https://wordpress.org/plugins/wp-user-frontend/, to let users create a custom post type in the front end.
Can you kindly post the function necessary to update the location field(s) for the GWP field in the database? My front end form has an address field with a unique ID.
I tried your function here – http://tempform.wpengine.com/documentation/geo-wp-formiable-pro-integration/ – but it did not work, I’m assuming the field names don’t line up since it’s for Formidable Pro.
Thank you so much,
AlvinJune 27, 2014 at 2:02 am #33548Alvin Bond
MemberActually I believe I figured it out – below is the code that worked in case somebody needs it in the future:
123456789101112131415161718function wpuf_new_post_form( $post_id, $form_id, $form_settings, $form_vars ) {$value = '';if ( $post_id ) {$value = get_post_meta( $post_id, 'meta_field_name', true ); // change meta_field_name to your own}include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );if ( function_exists( 'gmw_pt_update_location' ) ) {$args = array('post_id' => $post_id,'post_type' => 'post_type', // change post_type to your own'post_title' => get_the_title( $post_id ),'address' => $value);gmw_pt_update_location( $args );}}add_action('wpuf_add_post_after_insert', 'wpuf_new_post_form', 10, 3 );Is there anything wrong with the above code? It seems to work fine but just want to be sure. Thanks!
June 28, 2014 at 10:58 am #33547Eyal Fitoussi
Member@Alvin,
Thank you for the code. Indeed it is working but was generating warnings ( you would see with debug on ).
I updated and posted the code here. It should work when creating new posts and when updating existing posts.@Tom,
add the line of code:1add_action( 'frm_after_update_entry', 'gmw_save_frm_post_data', 10, 2 );to the end of the script. This is the hook to be used when updating a post.
Let me know if it works.
June 28, 2014 at 11:07 pm #33546Tom Poon
MemberThat’s brilliant Eyal! Just tested and everything is working fine now, and I found out how to prevent the exact position of the marker moving away from my lat/long data to the nearest house address/point of interest.
Simply add
123"loc:" in front of the hidden lat/long field like this;$title = 'loc:'. $values['item_meta'][109] .','. $values['item_meta'][108];Thanks!
June 29, 2014 at 7:38 pm #33545Eyal Fitoussi
MemberI am glad it is working and thanks for the tips Tom.
I will alter add the lat/lng use with Formidable Pro to the script I wrote.June 30, 2014 at 11:39 pm #33544Alvin Bond
MemberHi Eyal,
Thank you so much, your updated code worked much better!
If I am seeking customization work from you regarding extending the features of this plug-in, how do I contact you, and what is your rate?
Cheers
May 9, 2015 at 11:40 am #35841PinkishHue
MemberHello, thanks so much for sharing this code. I wanted to add information on how to use this for bbpress topics, which I finally have working after much trial and error!
Change instances of post to topic (e.g. post_id = topic_id) and instead of the wpuf action at the end, change to:
add_action(‘bbp_new_topic’, ‘gmw_update_location_via_wpuf’, 10, 1 );
add_action(‘bbp_edit_topic’, ‘gmw_update_location_via_wpuf’, 10, 1 );(and if you want to do it right, change all other instances of wpuf to something more relevant to your needs, but that’s not too important)
June 17, 2015 at 3:08 am #38466fredajt
MemberHi, the function for wpuf pro doesn’t works anymore, the hooks have changed and i think something else but i don’t know what
November 10, 2018 at 9:10 am #58177anticosti
MemberGreetings,
I am fighting like hell to get this working with all the latest Geo My WP and WP User Frontend Pro plugins.
Anyone could help me to get my custom post type “services” to work? I need:
01. The correct way to make it work with the “Custom Fields: Address Field” in WPUF Pro;
02. The correct code to put inside my theme’s functions.php file.Oh please, help me someone!
-
AuthorPosts
The topic ‘Add location field to custom post that users add on the front end?’ is closed to new replies.