Form: Send Notification

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_month value (see Recipe: Pricing package fields).
  • Toggles configured under Settings:
    • gd-send-notification-to-favourited-users
    • gd-send-notification-to-users-in-area
    • gd-send-notification-to-all-users
    • gd-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’s pn_per_month (default 10 if missing).

Submission processing

mam_gd_send_notification::send_notification($values):

  1. Verifies the submitter is signed in.
  2. Verifies the submitter is the listing’s author OR an admin OR a member of the listing’s accepted managers (returns Permission denied. otherwise).
  3. Reads default toggles (gd-send-notification-to-favourited-users etc.) and overrides them with the picked Send Type.
  4. Builds the recipient list:
    • Favorited path: read gd_favourite_users post meta from the listing.
    • Nearby path: query users within radius miles of the listing’s latitude / longitude using a Haversine SQL query against _user_lat / _user_lon user meta. Default radius is 100 miles, hard-coded at the call site.
    • All-users path: get_users(['fields' => 'ID']).
  5. Runs Hook: mam_geodirectory_send_notification_users to let extensions add or filter the recipients.
  6. For each recipient, builds a mam-push-notification message with title and content replacements and dispatches via mam_notification_send_message (mam-main contract).
  7. Increments pn_sent_{YYYY_MM} post meta on the listing.
  8. 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_message payload (use the mam-main notification log).
  • Send pn_per_month + 1 notifications. The button should disappear after the cap is hit and reappear on the first of the next month.

Variations

  • Add a custom audienceHook: 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 100 miles in send_notification(). To override in code, hook Hook: mam_geodirectory_send_notification_users and replace the nearby recipient 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 in mam_geodirectory_send_notification_users if you need to.

Verification

This article was last verified against:

  • Plugin: mam-geodirectory v2.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.


  • 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
Contents

    Need Support?

    Can’t find the answer you’re looking for? Don’t worry we’re here to help!