michaelpollak / ultimate-member-map

Geocode and display a number of wordpress users on a map using the Google Maps API.
GNU General Public License v3.0
0 stars 0 forks source link

UM Hook #1

Open troeim opened 3 years ago

troeim commented 3 years ago

Hi Michael Thanks for your open source Code. I am trying to build a tool for our website too, based on yours. However I am having trouble with the Ultimate Member (UM) hook. Do you update lat / long only on registration or also on profile update? Did you create lat / long already in UM or is it generated automatically from the code? Kind regards troeim

michaelpollak commented 3 years ago

Hy troeim, glad you can use it.

The lat / long is first created on registration but also updated every time the user updates his/her location profile field. I use the google geolocate API for this, see this line here https://github.com/michaelpollak/ultimate-member-map/blob/3bf9528f185e5c683270647eb34e4abcd65ee9bd/functions.php#L30

You pass it a name for your hometown, for example "Rafings" and it replies with lat / long for the most likely town. You will need a (free) API key for this, read up on it here: https://developers.google.com/maps/documentation/geocoding/overview

Hope this helps you out, mfg michael

troeim commented 3 years ago

Hi Michael Thanks for your quick reply.

The map is working, I can see my 'school' and a user with manually added coordinates. However I can't generate them when a user profile is updated.

I am opening a UM profile on website.com/profile/username Then I edit this profile: website.com/profile/username/?um_action=edit

When I update the profile, none of the hooks in my functions.php file in the childtheme are called. Not sure what's the reason for this. How to make sure that the Plugin UM is able to call the hook on submit?

Kind regards troeim

michaelpollak commented 3 years ago

Did you add a field to your register/update form? It's called "ort" in my codebase, it's referenced and explained in the comments within the code. Also I did not build a child theme, maybe your functions.php need some extra initialization code?