Google Maps – Store and retrieve address in Google Maps Field
Viewing 5 Posts - 1 through 5 (of 5 total)
Author | Posts |
---|---|
August 14, 2013 at 9:22 pm 6962 | |
erimathi | Hello,
I wanted the google maps field to store an address in a custom field I could use as a string to present in the post template. But I also wanted to have the address called back into the google maps field "Find address" box when the user edits the post.
I was able to achieve this using the following hack.
STEP 1 - Use the code Tareq gave me to store the Find Address in a custom field.
I put this code in my theme custom functions.
STEP 2 - Tweak this file;
plugins/wp-user-frontend-pro/class/render-form.php
(hope nobody on the awesome wedevs team is offended!)
Find this line of code, it should be near the end near of the file in a function called
"Function Map"
<input id="wpuf-map-add-<?php echo $attr['name']; ?>" type="text" value="" name="find-address" placeholder="<?php _e( 'Type an address to find', 'wpuf' ); ?>" size="30" />
Replace it with this code...
<input id="wpuf-map-add-<?php echo $attr['name']; ?>" type="text" value="<?php echo get_post_meta( $post_id, 'cf_address', true ); ?>" name="find-address" placeholder="<?php _e( 'Type an address to find', 'wpuf' ); ?>" size="30" />
That will call the stored address from the CF_ADDRESS custom field using Get_Post_Meta function and place it into the Find Address box during the rendering of the Google Map field in forms.
It works for me so far. Sorry if its an inelegant way of doing this but I am only new at this PHP business.
Of course this tweak may get blown away with updates to the plugin, so you will have to re-apply it after updates.
Love this plugin. Thanks.
Chris.
|
August 14, 2013 at 9:26 pm 6963 | |
chrishanratty | Oh no my code went off the page. Here it is again Find this;
Replace it with this….
|
August 14, 2013 at 11:13 pm 6973 | |
Tareq Hasan | Hope that will help some others 🙂 |
September 5, 2013 at 4:30 pm 7829 | |
jman057 | Hi Tareq, I can’t seem to get that function to work. I want to retain the written address to show in the post. I’ve tried sending to to a different custom field other than “address”, I’ve tried embedding it in a different function that I know executes, and I’ve tried removing the “if” conditional. None of the options seem to work. Any ideas? It doesnt need to go back to the address field if that helps? Thanks! Jamie |
January 6, 2014 at 1:30 am 14160 | |
Denis | change ‘ to ‘
|
March 5, 2014 at 7:17 pm 16207 | |
erimathi | Hi, cant seem to get this to work. If i understand correctly you are trying to get the address field to print out as a string in addition to the map? In that case where is the address supposed to print? |
Viewing 5 Posts - 1 through 5 (of 5 total)