This support ticket is created 5 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
A Support member has suggested using save_post hook to store the lat/lon coordinates.
But I couldn't any way to Latitude & Longitude. It is on text field (name attribute) called "toolset-extended-form-wpcf[test-google-map-address-01][latitude]" & "toolset-extended-form-wpcf[test-google-map-address-01][longitude]"
But I don't know how to access it from inside save_post or whatever suitable hook. Could you help me?
Sorry Shane, I didn't understand, You mean create 2 fields and manually add Latitude & Longitude? I am just looking way to save Latitude & Longitude in the database when publish/update the post. Currently, toolset saved only the location address/
The Latitude & Longitude values are being stored in the database but not as post meta. They will need to be retrieved from the wp_options table which would require a manual query.
The better option is to store your Latitude & Longitude as separate custom meta from the address itself so you can retrieve the values like regular custom fields.
"You mean create 2 fields and manually add Latitude & Longitude?"
Thanks Shane. I created two toolset custom fields called "wpcf-latitude" and "wpcf-longitude". I am trying to store those values on "wpcf-latitude" and "wpcf-longitude". Could you give a help to store them? Any sample code or link is much appreciated.
Then add a new JS custom js and set the "Where in site" option to "In Admin". Finally add the following to the editor and save it.
jQuery(".editor-post-publish-button").click(function() {
var cords = jQuery("input[name='wpcf[address]']").attr("data-coordinates");
var splitcords = cords.split(',');
jQuery("input[name='wpcf[latitude]']").val(splitcords[0].replace("{",""));
jQuery("input[name='wpcf[longitude]']").val(splitcords[1].replace("}",""));
});
Note you will need to replace "wpcf[address]" with the appropriate value. Lets say your field is called "Location" then the slug will be "wpcf-location". To add this to the code it will become "wpcf[location]"
I bind the code to the update button on the post, so it will fire when the button is clicked.