Skip Navigation

[Resolved] Geolocation – update location cookie and/or current location via wpv-geolocation

This support ticket is created 5 years, 5 months 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by laneV 5 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1319013

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?

#1319657

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.

#1321157

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.

#1321553

Thank you for checking, Christian. I'll work on implementing my own code/solution.