Signature
apply_filters( 'mam_geodirectory_send_notification_users', array $users, array $values );
| Parameter | Type | Description |
|---|---|---|
$users |
int[] | Resolved recipient WordPress user IDs — the union of favorited users, nearby users, or all users (per the picked Send Type). |
$values |
array | The full form values from the Send Notification submission. Use $values['send-type']['value'], $values['postid']['value'], etc. |
Returns: int[] — modified user ID list. You must return an array.
Purpose
The last filter in the recipient-resolution chain for the Send Notification form. By the time it fires:
- The submitter has been authorized (admin / owner / manager).
- The picked Send Type has been resolved against the configured labels.
- The favorited / nearby / all-users recipient set has been built.
This filter lets you mutate the final recipient list — adding people, removing people, swapping in a custom audience entirely. Pair with Hook: mam_gd_send_notification_types if you also want to add a new dropdown choice.
When it runs
In mam_gd_send_notification::send_notification():
if ( get_option( 'mam_geodirectory_send_notification_send-type' ) ) {
$users = apply_filters( 'mam_geodirectory_send_notification_users', $users, $values );
}
The gate (if option exists) means: this filter only fires when the plugin’s Send Notification form has been wired (the option holds the field ID). On installations where the form is unconfigured, the filter does not run.
Examples
Suppress a specific user
add_filter( 'mam_geodirectory_send_notification_users', 'my_app_suppress_test_user', 10, 2 );
function my_app_suppress_test_user( $users, $values ) {
return array_values( array_filter(
$users,
static fn( $id ) => (int) $id !== 12345
) );
}
Replace the entire audience for a custom Send Type
add_filter( 'mam_geodirectory_send_notification_users', 'my_app_audience_override', 10, 2 );
function my_app_audience_override( $users, $values ) {
if ( ($values['send-type']['value'] ?? '') === 'All vip subscribers' ) {
$vips = get_users( [ 'role' => 'vip', 'fields' => 'ID' ] );
return $vips;
}
return $users;
}
Cap to 1000 recipients
add_filter( 'mam_geodirectory_send_notification_users', 'my_app_cap_recipients', 10, 2 );
function my_app_cap_recipients( $users, $values ) {
return array_slice( array_unique( $users ), 0, 1000 );
}
Gotchas
- Filter only fires when the form’s
send-typefield is configured. If the optionmam_geodirectory_send_notification_send-typeis empty, the plugin uses the per-listing default toggles and never calls this filter. - Recipients are de-duplicated downstream. The plugin runs
array_unique($users)after this filter, so duplicates are harmless. $valuesshape is the Gravity Forms field values shape. Each field is['value' => ..., ...]— not the raw scalar. Use$values['postid']['value'], etc.- Always return an array. A non-array return breaks the recipient loop.
- Per-listing PN counter still increments. Even if you return zero recipients, the listing’s
pn_sent_{YYYY_MM}counter advances by 1 (the plugin checkscount($messages) > 0before incrementing — a zero-recipient submission does not increment it).
Verification
This article was last verified against:
- Plugin:
mam-geodirectoryv2.1.5 - Source:
includes/forms/send-notification-form.php
Re-verify whenever the gate option key changes, the Send Type matching logic switches to id-based instead of text-based, or the dispatch loop changes its de-duplication semantics.
Related articles
- Plugin: mam-geodirectory
- Form: Send Notification
- Hook: mam_gd_send_notification_types
Metadata
| Field | Value |
|---|---|
| Article type | Hook Reference |
| Plugin slug | mam-geodirectory |
| Applies to plugin version | 2.1.5+ |
| Category | Extending MAM Suite |
| Hook type | filter |
| Audience | PHP developer |
| Last verified | 2026-05-01 |
