Geo-location: Using an Events Calendar program to highlight events close to the user

As part of the development of the Farm Table site we were looking to add a geo-location feature to show a list of events within a certain distance of the currently logged in user’s address, information which is held in their private user profile.

My hopes were raised by the changelog of the Events Calendar Pro plugin, that mentioned that version 4.4.16 added the ability to include geo-location parameters in searches.

The geo-location features are usually used off the shelf in ECPro, via the Location parameters of the filterbar. What I needed to do was retrieve latitude and longitude values from the currently logged in user’s profile (ie user_meta values) and then use these values to power a search to show ‘events within x kilometres of the user’.

To store the values, we use Gravity Form’s User Registration add on (for user profile editing) and GeoMyWP and their Gravity Geolocation extension to do live lookups from Google’s geocoding service as the user is typing their address, to in turn feed a geocoder on the page, that then allows you to store any number custom meta values. It works pretty well:

When it comes to using this stored information to drive a list of ‘events near you’, the documentation was pretty scarce. I ended up reading source code to work out how it was done.

farmtable-Branding-Mockup-geo-location

 

Resources - 28 Nov 2019 - by Rob Jennings

About Rob Jennings

When he found himself embroiled in a conversation with someone talking about their ‘customer-centric core competencies’ he realised it was time to create a Web Design Agency that was less about self promoting buzz-words and more about people and giving them the tools to understand the web.

The idea behind We Push Buttons was to create an environment where business owners can learn about building their organisation, whether it be with an outstanding website, SEO or any other marketing ideas. Coming from the art industry and online retail background he knows first hand the needs of growing a business in a tough environment.