I have a custom function/shortcode that will allow a certain event to occur if the user is close enough to a CPT's location. In the CPT I store the locations lat and lng coords. I need access to the user's CURRENT location.
I have my shortcode wrapped in wpv-geolocation - I was hoping since the documentation says this enables the contents of wpv-geolocation will have backend access to location data. However, I don't see in the documentation how I can programmatically access the user's location data. Please advise 1) how I can access the users GPS coords in PHP or passing as atts to my shortcode and 2) is this current location data or stored location data?
I also found the cookie 'toolset_maps_location' which I can programmatically grab and use. However, this data seems to be the location the user was at when they first loaded the page, not up to date location data. I read the cookie data at home, and then drive several miles away and reloaded the page but the cookie location data did not change. Is there a way via toolset to either 1) force this cookie data to update with current location or 2) access current user location?
Hi, I don't know of any public APIs available for interacting with the User location via Toolset Maps, either with JavaScript or PHP. The geolocation shortcode is designed for interacting with geo-restricted contents internally, not providing access to the User's location publicly. I'll double-check with my 2nd tier team to be sure and let you know what I find out.
Okay after discussion with the team, my initial suspicion was correct. There are no public APIs available to retrieve the current User's location in a format other than a marker on a map, as described here:
https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/#displaying-current-visitor-location
Any other User location interactions would require custom code, or a feature request. I also inquired about the length of time a User's location is stored by the system, and I was told that the duration is tied to the length of the User's session.
If you'd like to request more public access possibilities for the User's location, I encourage you to submit your suggestion over here: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
This will put your request in front of the people who decide which features to include in upcoming versions of the software.
Thank you for checking, Christian. I'll work on implementing my own code/solution.