Send a targeted push notification to a listing’s followers

Goal

Give the owner or manager of a directory listing a button inside the mobile app that sends a push notification (and an optional email) to that listing’s followers — the app users who have favorited the listing. This is how a restaurant pushes “tonight’s specials” to regulars, or a venue alerts the people who saved it that an event time changed.

In MAM Suite, a listing’s followers are simply the users who have favorited it: whenever someone taps the favorite/heart control on a listing, their user ID gets stored on that listing, and that stored list is exactly who the Favorited audience reaches.

This article uses the GeoDirectory plugin (mam-geodirectory) — the MAM Suite plugin that turns WordPress posts into mobile directory listings — since the Send Notification feature is built right in.


Before you start

You will need:

  • MAM Suite with mam-main and mam-geodirectory active. GeoDirectory is what provides listings, the favorite control, and the Send Notification form.
  • Push notifications working for your app. Your iOS and/or Android push credentials must already be configured in Mobile App Manager so that any push can be delivered at all. If pushes are not yet delivering, fix that first — targeting is a separate layer on top.
  • The Send Notification form. GeoDirectory’s Send Notification form is a Gravity Form the platform generates for you — you do not build it by hand. It is materialized and registered (and its ID wired to the feature) automatically once the plugin is active; you only confirm it exists and is selected.
  • A pricing package with a sensible monthly push cap. The feature is rate-limited per listing per calendar month using the package’s pn_per_month value. If a listing’s package doesn’t set one, the cap defaults to 10.

How the audiences work

The Send Notification form can target one of three audiences, and “Followers” is the one this article is built around.

Audience Who it reaches How recipients are resolved
Followers (Favorited) Users who favorited this listing Reads the listing’s gd_favourite_users post meta
Nearby Users whose stored location is near the listing Haversine query against each user’s saved latitude/longitude, default radius 100 miles
All users Every app user All WordPress users

You can turn each audience on or off independently. To keep this a targeted-to-followers feature, leave the Favorited audience on and decide for yourself whether Nearby and All are worth exposing too. The three toggles are:

  • gd-send-notification-to-favourited-users
  • gd-send-notification-to-users-in-area
  • gd-send-notification-to-all-users

A separate pair of options holds the labels that appear in the in-app Send Type dropdown:

  • gd-send-notification-to-all-favorited-users (admin field “Send Notification to all Favorited Users”; default “Send to all users that Favorited”)
  • gd-send-notification-to-all-nearby-users (admin field “Send Notification to all Nearby Users”; default “Send to all nearby users”)

You’ll find both toggles and both label fields together on the Mobile App Manager → Geodirectory settings page. One thing worth knowing: there’s no label option for the All-users audience, because the standard Send Type dropdown only ever offers the Favorited and Nearby choices. That means the All-users toggle only comes into play in the legacy send path — unless you add a choice yourself with the mam_gd_send_notification_types filter.


Steps

1. Build (or identify) the Send Notification Gravity Form

You don’t build this form in the Gravity Forms editor at all — the platform generates it for you. Once mam-geodirectory is active, MAM creates the form, assigns it an ID, and registers it under the send_notification key. Inside the app, the user fills in four fields, which the plugin reads on submission by field slug, not by Gravity Forms field ID:

Title Slug Type
Message Title message-title text
Message message textarea (paragraph)
Send Type send-type select / dropdown
Listing ID postid hidden

At runtime, the Send Type dropdown’s choices are pulled from the label options above, and the postid hidden field fills in automatically with whichever listing the user is viewing. You won’t normally need to touch any of this — just confirm the form exists, which is the next step.

2. Point GeoDirectory at the form

Head to Mobile App Manager → Forms Manager and find the Send Notification form mapping. Since the form is code-generated, it’s usually already pointed at the auto-created form for you — just confirm it points at a valid form and save. (Behind the scenes, the feature reads this from the mam_geodirectory_send_notification option, which the platform sets automatically.)

3. Turn on the Followers audience and label it

On the Mobile App Manager → Geodirectory settings page:

  1. Enable gd-send-notification-to-favourited-users (admin field “Send Notification to Favorited users”) so the Favorited audience resolves to recipients.
  2. Set gd-send-notification-to-all-favorited-users to a friendly label such as “Send to everyone who favorited this.” This is what the listing owner sees in the Send Type dropdown.
  3. Then decide on the other two audiences. If you want this to be purely a followers feature, leave Nearby and All disabled. To also offer Nearby, enable gd-send-notification-to-users-in-area and set its label. Leave the All-users toggle off unless you’re sure you want it — with the standard dropdown it has no choice of its own, and turning it on can broaden a Favorited send to everyone.

Targeting note: turning off an audience’s toggle doesn’t remove its choice from the dropdown if the label is still set — it’ll still show up, just resolving to zero recipients. Keep each audience’s label and toggle in sync for the ones you actually want.

4. Author the push template

Whatever the user types becomes the title and content of the push. GeoDirectory dispatches it through the MAM notification system under the mam-push-notification type, which means the channel routing (push / email) and any wrapping template come from the matching entry in Mobile App Manager → Notifications Manager. Double-check that push delivery is enabled for that notification type — otherwise the message gets logged but never actually pushed.

5. Confirm the in-app button appears for the right people

The Send Notification button only shows on a listing’s detail screen when all of these are true:

  • The signed-in user is the listing’s owner (author), an accepted manager of the listing, or a site administrator. Regular followers cannot send.
  • A Send Notification form ID has been configured (step 2).
  • The listing has not hit its monthly push cap — the listing’s pn_sent_{YYYY_MM} counter is below the package’s pn_per_month (default 10).

In other words: favoriting a listing makes an ordinary app user a recipient — but only the owner, manager, or admin ever sees the send button.

6. Test the full loop

  1. As a test app user, favorite the listing.
  2. As the listing owner (or an admin), open the listing and tap Send Notification.
  3. Choose the Favorited / followers Send Type, enter a title and message, and send.
  4. Confirm the favoriting user receives the push. Confirm a non-follower does not.
  5. Send enough notifications in one month to exceed pn_per_month and confirm the button disappears, then reappears on the first of the next month.

What happens when the form is submitted

If you’re debugging delivery, here’s the server-side sequence, step by step (in mam_gd_send_notification::send_notification()):

  1. Confirms the submitter is signed in.
  2. Authorizes the submitter — must be the listing’s author, an admin, or an accepted manager; otherwise returns “Permission denied.”
  3. Resolves the picked Send Type against the configured labels, then builds the recipient list:
    • Followers: reads gd_favourite_users from the listing.
    • Nearby: Haversine SQL query within the radius (default 100 miles) against user latitude/longitude meta.
    • All: all WordPress user IDs.
  4. Runs the mam_geodirectory_send_notification_users filter so code can add, remove, or replace recipients.
  5. De-duplicates the list, builds one mam-push-notification message per recipient, then hands the whole batch to the mam_notification_send_message action in a single call.
  6. Increments the listing’s pn_sent_{YYYY_MM} counter (only when at least one message was built).
  7. Returns “Notifications have been sent.” — worth noting, this message comes back even when the audience resolved to zero recipients; an empty audience is not treated as an error.

Troubleshooting

The Send Notification button doesn’t appear. Walk back through the three conditions in step 5: is the viewer really the owner/manager/admin, is the form ID set, and has the listing hit its monthly cap? That cap trips people up more than anything else here — but it resets on the first of every month.

The push is “sent” but nobody got it. There are two layers worth checking. First, the Favorited audience might simply be empty — confirm a real user has actually favorited the listing (remember, the success message appears even with zero recipients). Second, confirm push is enabled for the notification type under Notifications Manager, and that app-wide push credentials are valid.

Followers near a different location got it too. That’s a sign the Nearby audience is enabled and got selected alongside Followers. For a strictly-followers feature, disable gd-send-notification-to-users-in-area.

I need a different audience (e.g., season-ticket holders). You can add a dropdown choice with the mam_gd_send_notification_types filter, then turn that choice into an actual recipient set with the mam_geodirectory_send_notification_users filter. Both are developer hooks — see the related articles.


  • Form: Send Notification (plugin reference for the same feature)
  • Recipe: Pricing package fields (where pn_per_month is set)
  • Hook: mam_geodirectory_send_notification_users (override the recipient list)
  • Hook: mam_gd_send_notification_types (add a custom audience choice)
  • GeoDirectory notification types (the mam-push-notification template and others)

Verification

Drafted against:

  • mam-geodirectory/includes/forms/send-notification-form.php (mam_gd_send_notification::send_notification())
  • mam-geodirectory/mam-geodirectory.php (form wiring, favorites, tab bar button registration)
  • mam-main/includes/notifications-manager/dispatcher/class-mam-notification-dispatcher.php (dispatch + channel routing for mam-push-notification)
  • Reference docs: mam-geodirectory/user_docs/04b-form-send-notification.md, 07m-hook-mam-geodirectory-send-notification-users.md, 07o-hook-mam-gd-manage-favorites.md, 06-notification-types.md
Was this article helpful?
Contents

    Need Support?

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