Hook: mam_main_skip_tab_bar_button

Purpose

Per-item visibility filter for tab-bar buttons. Lets a sibling plugin hide a registered button on a per-item / per-user basis without owning the button definition.

Runs before mam_main_add_tab_bar_item_{slug} dispatch — preferable to gating inside an “add” filter you don’t own, because the skip filter short-circuits earlier and doesn’t depend on cooperating with the button’s registered handler.


Signature

$tab_bar = apply_filters(
    'mam_main_skip_tab_bar_button',
    array $tab_bar,
    array $data_array
);
Parameter Type Description
$tab_bar array The button definition (id, title, etc.)
$data_array array The current item being rendered (post id, post type, etc.)

Returns: array — $tab_bar to keep the button, [] to hide it.


Example: hide the generic Share button from staff

add_filter( 'mam_main_skip_tab_bar_button', function ( array $tab_bar, array $data_array ): array {

    if ( ( $tab_bar['id'] ?? '' ) !== 'share_listing' ) {
        return $tab_bar;
    }

    if ( $this->current_user_is_staff_for( $data_array['id'] ?? 0 ) ) {
        return array();   // hide
    }

    return $tab_bar;
}, 10, 2 );

Skip vs. add filter

Pattern Use when
mam_main_skip_tab_bar_button (this filter) You want to hide a button you don’t own
mam_main_add_tab_bar_item_{slug} returning [] You own the button and want to hide it for some items

The skip filter is preferable when you don’t own the button, because:

  • It runs first (before the add filter)
  • You don’t need to know the button’s registered slug — match by $tab_bar['id']
  • You don’t fight with the button’s add handler

Gotchas

  • Returning [] hides; returning $tab_bar keeps. Don’t return false or null.
  • $tab_bar['id'] is the dispatch key. Always check it before deciding.
  • Hot path. Fires once per tab-bar button per item. Cache role / context lookups.
  • You don’t see whether the item’s add handler would have hidden the button anyway. Skip and add are independent gates; both can hide.

  • Recipe: Configure the tab bar
  • Hook: mam_main_add_tab_baritem{slug}
  • Hook: mam_tab_manager

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!