How it Works

This plugin creates a shortcode [pmpro_membership_maps] you can place on any page of your WordPress site. Membership Maps will also display automatically on the Member Directory and Profiles Add On frontend pages.

Settings | Shortcode Attributes | Member Directory and Profiles Integration | Google Maps API Key | Action and Filter Hooks | Screenshots


Installation

  1. PMPro Plus members can install the add on via the Memberships > Add Ons admin page.
  2. Or, download the plugin file and upload the pmpro-membership-maps directory to the /wp-content/plugins/ directory of your site.
  3. Activate the plugin through the Plugins menu in the WordPress admin.

Settings

  1. This plugin requires Paid Memberships Pro to be installed and activated.
  2. By default, the map will geocode the member’s “Billing Address”. Navigate to Memberships > Settings > Payment Gateway & SSL in the WordPress admin. Confirm the “Show Billing Address Fields” setting is set to “Yes”. If you need to use a different member address for the map, please refer to this guide.
  3. Next, enter your Google Maps API Key on the Memberships > Settings > Advanced Settings page in the WordPress admin. Click here for help obtaining up your Google Maps API Key.

Shortcode Attributes

Attribute Default Type Description
height 400 int Height of the map. The height is restricted to a pixel value.
width 100 int Width of the map. The width of the map makes use of a percentage value to maintain responsiveness.
zoom 8 int Zoom level of your map. The lower the value, the
ID 1 mixed Specify an ID for your map to identify it in CSS classes and code recipes. This attribute is required if you want to show more than one map on a single page.
infowindow_width 300 int The maximum width of an info window in pixels.
levels false mixed Specify level ID’s here to only show markers on the map of specific membership levels. More than one ID can be comma separated.
link* true boolean This determines if the contents of the info window can be turned into links to the member’s profile page.
avatar_size* 64 int The size of the avatar displayed in the info window.
show_avatar* true boolean Determines if a members avatar should be displayed or not.
show_email* true boolean Determines if a member’s email address should be displayed or not.
show_level* true boolean Determines if a member’s level should be displayed or not.
show_startdate* true boolean Determines if a member’s start date should be displayed or not.
avatar_align* NULL string Specify the position of the member’s avatar. Choose between none, left, center, right.
fields* NULL string Offers support for custom fields generated by the Register Helper Add On. Field names can be comma separated in this attribute and will show in the info window.

* These fields integrate directly with the Member Directory and Profiles Add On. The Membership Maps Add On will automatically use the values of these fields when setting up your Membership Directory.


Member Directory and Profile Pages Add On Integration

Your map will automatically display on the Member Directory and Profile pages, inheriting the shortcode attributes of that Add On for rendering the map. You can add additional shortcode attributes from the Membership Maps directly to the shortcodes used by the directory or profile page. See the example below, which adds the infowindow_width attribute to the Directory shortcode:

[pmpro_member_directory levels="1,2,3" infowindow_width="350"]

If you do not want to display a map automatically on these pages, you must unhook the actions in the Membership Maps Add On using a recipe like the one below:


Obtaining Your Google Maps API Key

This plugin requires you to create a Google Maps API Key enabled for the Google Maps Javascript API & Geocoding API. You must use an active G Suite or Gmail Account in order to leverage this API.

Updated 2020-08-13: The Google Maps Platform includes a free $200 monthly credit for API usage. This would allow a daily limit of 2,000 Geocoding API requests and 10,000 Maps API requests. View current pricing »
  1. Navigate to https://console.cloud.google.com/.
  2. Click ‘Select Project’ to get a view of all current projects for your profile.
  3. Click ‘New Project’.
  4. Name your project and (optionally) assign your project to an organization.
  5. Click ‘Create’.

Once you have created a new project, you will see a notification window. Click “View” to see an overview of your project.

  1. Hover over ‘APIs & Services’ and click ‘Credentials’ in the left navigation pane.
  2. Click ‘Create Credentials’.
  3. Select ‘API Key’ to generate your API Key.
  4. In your WordPress admin, navigate to Memberships > Settings > Advanced Settings. Enter in your API key under the “Google Maps API Key” field.

Now that your API Key is created, you must enable the Google Maps Javascript API for your API Key.

  1. Click ‘Library’.
  2. Search for Google Maps Javascript API. Select the first option that comes up.
  3. Click to Enable this service.
  4. You’ll then be redirected to an overview of your Google Maps API key. Click ‘APIs’ in the left navigation pane.
  5. Click on ‘Geocoding API’.
  6. Click to Enable this service.

After completing these steps your API Key will be properly configured with the services needed to display membership maps on your WordPress site.

Note: You must link a Billing Account to your Google Cloud Platform Account to use these APIs. Click here to read Google’s documentation on linking your Billing Account.

Action and Filter Hooks

apply_filters( 'pmpromm_marker_attributes', $marker_attributes );
apply_filters( 'pmpromm_default_map_notice', $notice );
apply_filters( 'pmpromm_google_maps_libraries', $libraries );
apply_filters( 'pmpromm_default_map_start', array $default_start, $ID );
apply_filters( 'pmpromm_override_first_marker', bool $override_first_marker_location, $ID );
apply_filters( 'pmpro_membership_maps_sql_parts', $sql_parts, $levels, $s, $pn, $limit, $start, $end );
apply_filters( 'pmpro_membership_maps_sql', $sqlQuery, $levels, $s, $pn, $limit, $start, $end, $order_by, $order );
apply_filters( 'pmpromm_return_markers_array', array $marker_array );
apply_filters( 'pmpromm_profile_url', string $profile_url );
apply_filters( 'pmpromm_view_profile_text', string __( 'View Profile', 'pmpro-membership-maps' ) );
apply_filters( 'pmpromm_marker_content_order', array $marker_content_order );
apply_filters( 'pmpromm_member_address_after_checkout', string $member_address, int $user_id, MemberOrder object $morder );
apply_filters( 'pmpromm_single_map_address_geocode', string $member_address, WP_User object $pu );
do_action( 'pmpromm_geocode_response', $request_body, MemberOrder object $morder );
apply_filters( 'pmpromm_geocode_return_array', array( 'lat' => $lat, 'lng' => $lng ), $request_body, $addr_array, $morder );
apply_filters( 'pmpromm_enable_geocode_error_email', bool $mail_error );

Screenshots

Membership Map for all members in the Member Directory frontend page
Membership Map for all members in the Member Directory frontend page

Membership Map on a single Member Profile frontend page
Membership Map on a single Member Profile frontend page