Signature
apply_filters( 'mam_special_offers_deals_allowed', int $max, array $data_array );
| Parameter | Type | Description |
|---|---|---|
$max |
int | The default cap on the number of offers behind the Edit Deals button. The plugin’s caller passes 20. |
$data_array |
array | The listing context the tab bar is being built for. Keys include at least id (the parent listing post ID). |
Returns: int — the resolved cap. You must return it.
Purpose
Caps how many offers a single listing can have when the in-app Edit Deals tab bar button is built. The button sits on a listing’s detail screen; tapping it shows one row per existing offer plus an Add Offer row. The cap controls when the Add Offer row is suppressed.
The default of 20 is generous on purpose — it’s a soft UX cap, not a database limit. Increase it for power-user apps; lower it for venue-owner apps where letting one venue post 20 concurrent offers would clutter the home feed.
This filter does not affect:
- The four-slot meta-box UI on the parent post’s edit screen (that’s a hard UI cap).
- The home-screen featured-offers feed (which returns every offer with
special-offer-featured-listing == 'yes'). - The nearby-offers feed (which returns every published offer within radius).
It only affects the Edit Deals button’s Add Offer row.
When it runs
Once per Edit Deals tab bar build, inside mam_special_offers_tab_bar_manager::mam_app_settings_tab_bar_button_edit_deals() (includes/mam_special_offers_tab_bar_manager.php):
$deals_allowed = apply_filters( 'mam_special_offers_deals_allowed', 20, $data_array );
// ...
if ( count( $offers ) <= $deals_allowed ) {
// Add the "Add Offer" row to the button.
}
The comparison is less-than-or-equal-to: the Add Offer row appears as long as the existing offer count is at or below the cap. Returning 20 allows up to 21 entries to appear in the form list (20 offers + Add Offer). Existing offers are always listed regardless of cap — only the Add Offer affordance is gated.
Default behavior
mam_special_offers_deals_allowed → 20
There’s no per-role or per-app option for this. The default is hard-coded in the filter call; only this hook can override it.
Examples
One-offer-per-listing (single-promo apps)
add_filter( 'mam_special_offers_deals_allowed', static fn () => 1 );
Once a listing has its first offer, Add Offer disappears. The owner has to delete the existing offer (via the form’s Delete Offer checkbox) before they can add a replacement.
Different cap per parent post type
add_filter( 'mam_special_offers_deals_allowed', 'my_app_offer_cap', 10, 2 );
function my_app_offer_cap( $max, $data_array ) {
$post_type = get_post_type( $data_array['id'] );
if ( 'product' === $post_type ) {
return 5;
}
return $max;
}
Tighter cap for free venues, looser for premium
add_filter( 'mam_special_offers_deals_allowed', 'my_app_premium_offer_cap', 10, 2 );
function my_app_premium_offer_cap( $max, $data_array ) {
$author_id = (int) get_post_field( 'post_author', $data_array['id'] );
$is_premium = get_user_meta( $author_id, 'is_premium_venue', true );
return $is_premium ? 50 : 3;
}
Gotchas
- The cap is on the Add Offer affordance, not on the offers list. A listing with 100 offers will still surface all 100 in the Edit Deals list — the user just won’t be able to add a 101st. There’s no path here to truncate the existing list; if you need that, subscribe to Hook: mam_special_offers_skip_tab_bar_button and trim
$button['source']yourself. - Comparison is
count($offers) <= $deals_allowed, not<. Returning0does not suppress the button entirely on a listing with no offers —count([]) <= 0is true, so Add Offer is still shown. To unconditionally hide the button, usemam_special_offers_hard_skip_tab_bar_buttoninstead. $data_arrayshape varies by caller. It’s the listing context the tab bar manager was given; the only key the plugin itself reads isid. Don’t rely on other keys without verifying upstream.- Returning a non-integer pollutes the comparison. Cast to
intif you compute the cap from string input or option values.
Verification
This article was last verified against:
- Plugin:
mam-special-offersv2.1 - Source:
mam-special-offers/includes/mam_special_offers_tab_bar_manager.php
Re-verify whenever the default cap (20) changes, the comparison operator (<=) changes, the Add Offer row construction moves out of the cap branch, or the $data_array shape passed to the filter changes.
Related articles
- Plugin: mam-special-offers
- Recipe: Let venue owners manage offers from the app
- Hook: mam_special_offers_skip_tab_bar_button — final pass over the same button
- Hook: mam_specials_get_post_radius
Metadata
| Field | Value |
|---|---|
| Article type | Hook Reference |
| Plugin slug | mam-special-offers |
| Applies to plugin version | 2.1+ |
| Category | Extending MAM Suite |
| Hook type | filter |
| Audience | PHP developer |
| Last verified | 2026-05-01 |
