Goal
Configure the Send Notification form so a listing’s owner or manager can broadcast a push notification (and an optional email) from inside the mobile app, to one of three audiences:
- Users who have favorited the listing.
- Users near the listing (Haversine within 100 miles by default).
- All app users.
The form is rate-limited per listing per calendar month using the package’s pn_per_month cap.
Prerequisites
- A Gravity Form for sending notifications.
- That form’s ID configured under Mobile App Manager → Geodirectory → Settings → GeoDirectory: Send Notification.
- The pricing package(s) used by your listings have a sensible
pn_per_monthvalue (see Recipe: Pricing package fields). - Toggles configured under Settings:
gd-send-notification-to-favourited-usersgd-send-notification-to-users-in-areagd-send-notification-to-all-usersgd-send-notification-to-all-favorited-users(label shown in the Send Type dropdown)gd-send-notification-to-all-nearby-users(label shown in the Send Type dropdown)
Form fields
mam_gd_form_manager::get_fields('send_notification') returns:
| ID | Title | Slug | populate_with_key | Type |
|---|---|---|---|---|
| 1 | Message Title | message-title |
title |
text |
| 2 | Message | message |
message |
textarea |
| 3 | Send Type | send-type |
send_type |
select |
| 4 | Listing ID | postid |
id |
hidden |
Field 3’s choices are populated dynamically from the labels above (gd-send-notification-to-all-favorited-users and gd-send-notification-to-all-nearby-users). Hook: mam_gd_send_notification_types lets you append additional choices.
Tab bar button gating
The Send Notification tab bar button (built in mam_app_settings_tab_bar_button_send_notifications) only appears when:
- The viewer is the listing’s owner, manager, or admin.
- A Send Notification form ID is configured.
- The listing’s
pn_sent_{YYYY_MM}post-meta count is below the package’spn_per_month(default10if missing).
Submission processing
mam_gd_send_notification::send_notification($values):
- Verifies the submitter is signed in.
- Verifies the submitter is the listing’s author OR an admin OR a member of the listing’s accepted managers (returns
Permission denied.otherwise). - Reads default toggles (
gd-send-notification-to-favourited-usersetc.) and overrides them with the picked Send Type. - Builds the recipient list:
- Favorited path: read
gd_favourite_userspost meta from the listing. - Nearby path: query users within
radiusmiles of the listing’slatitude/longitudeusing a Haversine SQL query against_user_lat/_user_lonuser meta. Default radius is 100 miles, hard-coded at the call site. - All-users path:
get_users(['fields' => 'ID']).
- Favorited path: read
- Runs Hook: mam_geodirectory_send_notification_users to let extensions add or filter the recipients.
- For each recipient, builds a
mam-push-notificationmessage withtitleandcontentreplacements and dispatches viamam_notification_send_message(mam-main contract). - Increments
pn_sent_{YYYY_MM}post meta on the listing. - Returns
Notifications have been sent.
The plugin returns success even when $users is empty — the callsite assumes “no recipients” is not an error condition.
Steps to enable
1. Build the Gravity Form
Match the four fields above by slug (the plugin walks the form values by slug, not by Gravity Form field ID). The Send Type dropdown can be left empty in the form editor — the plugin populates choices at runtime.
2. Wire the form ID
Go to Mobile App Manager → Geodirectory → Settings → GeoDirectory: Send Notification. Pick your form. Save.
3. Configure labels and audiences
Set gd-send-notification-to-all-favorited-users (e.g., “Send to all users that Favorited”) and gd-send-notification-to-all-nearby-users (e.g., “Send to all nearby users”) under Settings. These labels become the dropdown choices.
If you want to remove an audience entirely, untick its enabling toggle (e.g., set gd-send-notification-to-users-in-area to no). The dropdown still shows the label but the recipient resolution will skip the audience.
4. Verify
- Open the app as a listing manager. The Send Notification button should appear on the listing’s detail screen.
- Send a test notification with each Send Type. Confirm the recipient list is correct in the resulting
mam_notification_send_messagepayload (use the mam-main notification log). - Send
pn_per_month + 1notifications. The button should disappear after the cap is hit and reappear on the first of the next month.
Variations
- Add a custom audience — Hook: mam_gd_send_notification_types adds choices to the dropdown; Hook: mam_geodirectory_send_notification_users lets you turn that choice into a recipient set.
- Tighten the nearby radius — the radius is currently hard-coded to
100miles insend_notification(). To override in code, hook Hook: mam_geodirectory_send_notification_users and replace thenearbyrecipient list with your own Haversine query. - Adjust the per-message recipient cap — the plugin de-duplicates with
array_unique()but does not impose a maximum. Cap downstream inmam_geodirectory_send_notification_usersif you need to.
Verification
This article was last verified against:
- Plugin:
mam-geodirectoryv2.1.5 - Source:
includes/forms/send-notification-form.php - Source:
includes/mam_gd_form_manager.php - Source:
includes/mam_gd_tab_bar_buttons.php
Re-verify whenever the recipient resolution logic in send_notification() changes, the per-listing PN counter (pn_sent_{YYYY_MM}) format changes, or the dropdown’s runtime choice population in add_field_features() changes.
Related articles
- Plugin: mam-geodirectory
- Recipe: Configure the GeoDirectory settings page
- Recipe: Pricing package fields
- Listing tab bar buttons
- Hook: mam_gd_send_notification_types
- Hook: mam_geodirectory_send_notification_users
- GeoDirectory notification types
Metadata
| Field | Value |
|---|---|
| Article type | Recipe (Admin) |
| Plugin slug | mam-geodirectory |
| Applies to plugin version | 2.1.5+ |
| Category | Building Your App |
| Audience | WordPress admin |
| Estimated time | 10 minutes |
| Last verified | 2026-05-01 |
