Priority conventions for phone-data subscribers

Summary

mam_get_phone_data_before_send has ~70 subscribers across the MAM Suite. Their relative ordering matters — some sections depend on others having already injected. The convention below has been observed by every existing subscriber for years; new code should follow it.


The priority bands

Priority Use Example subscribers
1 Base settings (theme, branding, layout primitives) mam_app_settings::manage_phone_data
10 Default cohort — content providers, sibling plugins mam-geodirectory, mam-special-offers, mam-chat-manager, mam-forms-manager, mam-inapp-purchase-manager, mam-user-roles
99–100 Late-running enrichments (run AFTER default cohort) mam-faceted-search (100), mam-localize (99), mam-wedassist (99), mam-agora (99), mam-woocommerce-single-storefront (99), mam-gd-scanner-manager (99)
199 Form-state validation pass mam_user_role_form_manager::process_last_json_check
999+ Niche overrides (weather, delivery, payment processors) mam-nws-weather (999), mam-woocommerce-delivery (999), mam-wc-heartland-payments (999)
1000 home_cats injection MAM_Main_Manager::manage_phone_datafrozen contract
1001+ Use-case-specific total overrides mam-meal-genie (9999), mam-medicoach (9999), mam-par-transport (9999), mam-tsl-previewer (9999), mam-welcome-to-hyde-park (1001)

Critical ordering contracts

home_cats runs at priority 1000

MAM_Main_Manager::manage_phone_data builds the home-screen category structure. Every subscriber that contributes to home_cats must run before priority 1000 — otherwise its category won’t be picked up.

If you need to influence the home-screen home_cats, register at priority < 1000 (10 is fine).

Use-case overrides run at 9999

Use-case plugins like mam-meal-genie and mam-medicoach need to fully replace sections of the response. They register at priority 9999 to run last. If your sibling plugin needs to read final values, register at 9999+.

GeoDirectory before GeoFilters

Both register at priority 10 (default), but mam-geofilters expects mam-geodirectory‘s listings to already be present. The implicit ordering depends on registration order — if you change registration order in register_*() methods, you can break GeoFilters silently.

Chat before notifications-manager

Similar: mam_chat_manager injects thread counts; mam_notification_manager reads them to compute notification badges. Both at priority 10 — registration order matters.


Choosing a priority for new code

If your subscriber… Use priority
Reads no other data, only injects its own 10
Adds to home_cats 10 (must run before 1000)
Reads listings injected by another plugin 100
Validates form state (form-after submission state) 199
Replaces a section the use-case bundle should override 10 (don’t try to compete with 9999)
Performs a final total override (use-case plugin) 9999

When in doubt: priority 10. It’s where 80% of subscribers live and ordering surprises are unlikely.


Anti-patterns

  • Don’t register at priority 1000 unless you’re injecting something that depends on every other subscriber’s data. That slot is home_cats.
  • Don’t register at priority -1 / 0 to run “first” — base settings owns priority 1; the convention starts there.
  • Don’t depend on home_cats from priority 999. Run after 1000 (e.g., 1001) instead.
  • Don’t try to invert ordering with remove_filter + add_filter — the registration order in mam-main’s bootstrap is intentional.

Diagnosis

apply_filters ordering is “lowest priority first.” To enumerate current subscribers in order:

global $wp_filter;
$cb = $wp_filter['mam_get_phone_data_before_send'] ?? null;
if ( $cb ) {
    foreach ( $cb->callbacks as $priority => $callbacks ) {
        echo "Priority $priority:n";
        foreach ( $callbacks as $cb_id => $cb_def ) {
            echo "  - $cb_idn";
        }
    }
}

  • Phone data pipeline overview
  • Phone data pipeline phases
  • Mobile JSON shape
  • Hook: mam_get_phone_data_before_send
  • Hook: mam_local_app_data

Metadata

Field Value
Article type Plugin Overview
Plugin slug mam-main
Applies to plugin version 2.1.11+
Category Extending MAM Suite
Audience PHP developer
Last verified 2026-05-02
Contents

    Need Support?

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