Adding profile fields to Google Maps: BP profile Maps

This post is similar to mine:

I want to add a custom Buddypress profile field like Phone number to the body of each google map marker.

Is this possible?


  • Vladislav


    With just a little bit of custom code, this shouldn't be a problem. The add-on exposes a filter called "agm_google_maps-bp_profile_map-location_markup", which allows you to change the entire content of marker description. This filter will be called for each of your users individually, and the function hooked up to it can accept up to 3 arguments - the first one will be the marker content markup generated this far, the second one will be your user's ID (so you can use this to get the XProfile field values etc), and the last one will be the user's address. Anything that this function returns will be used as the marker body.

    Please, keep in mind that, for performance reasons, your user markers are cached until something changes in their profile. Geo-locating users and generating their markers can be time-consuming, especially as the number of your users grows higher, which is why the entire generated markup is stored in cache to speed things up. So, making any changes via this filter won't affect the actual output until this cache is cleared. Fortunately, the plugin allows you an easy way of doing this via the "Fix and Repair" add-on. Activating this add-on gives you an option to rebuild your BuddyPress profile maps markers with a single click. I hope this helps.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.