Hook: mam_final_button_settings

Purpose

Last-chance per-button override. Fires after mam_tab_manager so subscribers can apply final values that should win over earlier enrichment.

Use this filter when you need to guarantee your override survives even if another subscriber to mam_tab_manager would have stomped your value.


Signature

$button = apply_filters( 'mam_final_button_settings', array $button );
Parameter Type Description
$button array The (already-enriched) button definition

Returns: array — the final button.


Order in the pipeline

For each button in role's button array:
    apply_filters('mam_app_settings_get_buttons', ...)            ← read
    For each button:
        $button = apply_filters('mam_tab_manager', $button);      ← enrich (~43 subscribers)
        $button = apply_filters('mam_final_button_settings', $button);  ← final overrides ← THIS HOOK
        ... merge into response

Example: enforce visibility hard

add_filter( 'mam_final_button_settings', function ( array $button ): array {

    // For my plugin's button: visibility is computed from a custom flag,
    // not the admin toggle.
    if ( ( $button['id'] ?? '' ) !== 'my_plugin_button' ) {
        return $button;
    }

    $button['visible'] = $this->should_show_for_current_user() ? 'on' : 'off';

    return $button;
}, 10 );

When to use this vs. mam_tab_manager

Use mam_tab_manager when… Use mam_final_button_settings when…
You’re enriching a button you own You need to guarantee your value survives later subscribers
You’re injecting per-button defaults You’re overriding what other subscribers wrote
Your work is in the normal enrichment flow You’re applying business-rule-driven overrides

In practice, most code uses mam_tab_manager. The “final” filter is a safety valve.


Gotchas

  • Hot path. Fires once per button per phone-data build.
  • Don’t use this for normal enrichment. That’s mam_tab_manager. The “final” filter is for overrides only.
  • Last-writer-wins among final-filter subscribers. Two subscribers writing the same key produces the later-registered subscriber’s value.
  • visible = 'off' at this stage hides the button; the calling code checks visible === 'on' before rendering.

  • Recipe: Add a button
  • Hook: mam_tab_manager
  • Hook: mam_app_settings_get_buttons
  • Button array storage

Metadata

Field Value
Article type Hook Reference
Plugin slug mam-main
Applies to plugin version 2.1.11+
Hook type filter
Audience PHP developer
Frozen contract yes
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!