Hook: mam_gd_send_notification_types

Signature

apply_filters( 'mam_gd_send_notification_types', array $choices );
Parameter Type Description
$choices array Array of ['id' => ..., 'text' => ...] entries that populate the Send Type dropdown.

Returns: array — modified choices. You must return an array.


Purpose

Lets you add new audience choices (or remove/reorder the built-in ones) in the Send Notification form’s Send Type field. The plugin populates two defaults from the configured labels (gd-send-notification-to-all-favorited-users and gd-send-notification-to-all-nearby-users); this filter runs after those have been added.

To handle a new choice on submission, pair this filter with Hook: mam_geodirectory_send_notification_users — that filter receives the resolved recipient list and the form values, including the picked Send Type, and lets you pivot the recipient set on it.


When it runs

In mam_gd_form_manager::add_field_features() for the send_notification form’s field 3:

$field['choices'] = [];
$field['choices'][] = [ 'id' => '1', 'text' => $favorited_label ];
$field['choices'][] = [ 'id' => '2', 'text' => $nearby_label ];
$field['choices'] = apply_filters( 'mam_gd_send_notification_types', $field['choices'] );

The filter runs every time the Send Notification form definition is built — typically when the app fetches the form on demand.


Examples

Add an “All staff” audience

add_filter( 'mam_gd_send_notification_types', 'my_app_add_staff_audience' );

function my_app_add_staff_audience( $choices ) {
    $choices[] = [
        'id'   => '3',
        'text' => 'All staff and managers',
    ];
    return $choices;
}

add_filter( 'mam_geodirectory_send_notification_users', 'my_app_resolve_staff_audience', 10, 2 );

function my_app_resolve_staff_audience( $users, $values ) {
    if ( ($values['send-type']['value'] ?? '') === 'All staff and managers' ) {
        $listing_id = (int) $values['postid']['value'];
        $managers = apply_filters( 'mam_get_group_members_for_post_id', [], $listing_id, 'accepted', 'manager' );
        $staff    = apply_filters( 'mam_get_group_members_for_post_id', [], $listing_id, 'accepted', 'staff' );
        return array_unique( array_merge( $managers, $staff ) );
    }
    return $users;
}

Remove the “Nearby” choice

add_filter( 'mam_gd_send_notification_types', 'my_app_drop_nearby' );

function my_app_drop_nearby( $choices ) {
    return array_values( array_filter(
        $choices,
        static fn( $c ) => $c['id'] !== '2'
    ) );
}

Gotchas

  • id and text are both meaningful. The plugin’s submission handler matches the picked choice by the text value against the option labels — not by id. Make sure new choices have a text you can recognise in your mam_geodirectory_send_notification_users callback.
  • Ordering is preserved. The dropdown shows entries in the order returned. Insert in the position you want.
  • Always return an array. Returning non-array breaks the form definition.

Verification

This article was last verified against:

  • Plugin: mam-geodirectory v2.1.5
  • Source: includes/mam_gd_form_manager.phpadd_field_features('send_notification')

Re-verify whenever the Send Notification form’s field IDs change, the submission handler in send-notification-form.php switches from text-matching to id-matching, or the default labels are sourced from different option keys.


  • Plugin: mam-geodirectory
  • Form: Send Notification
  • Hook: mam_geodirectory_send_notification_users

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
Contents

    Need Support?

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