Skip to main content

benecaster_user_tier_for_show

Filter Free

Filters the tier slug benecaster_get_user_tier_for_show() returns for a viewer on a show. The value entering the filter is the slug from the user’s active feed token, or an empty string when there is none.

Use it to change which tier the website names and ranks for a viewer: what benecaster_tier_gate compares with min_tier, what benecaster_subscribe’s panel describes, and what a template calling benecaster_get_user_tier_for_show() reads. Return an empty string to treat the user as unsubscribed in those places.

It opens no episodes. The episode page, the feed and benecaster_get_user_holdings() all read the membership system’s live tiers, never this filter, so the website opens an episode exactly when the listener’s feed would carry it. A tier returned here only reaches benecaster_episode_is_accessible as its $tier_slug argument.

To grant access without a membership (a gift, a grace period, a course completion), use a standalone grant: return its slug from benecaster_entitlement_grant_slugs, and the episodes reach the listener’s feed and the website alike. To open one page by a rule of your own, filter benecaster_episode_is_accessible; that opens the website only, never the feed.

benecaster_subscribe follows it. When a callback returns a different slug, the shortcode’s panel for a member who already holds a plan, and the tier cards it hides, describe a subscriber at the returned tier. The viewer’s own token type and subscription are ignored. Returning '' or public gives the signed-out view: no panel and every card. So a grace-window callback like the one below also stops the shortcode selling a plan to that subscriber during the window. A callback that returns the tier unchanged changes nothing.

Parameters

Name Type Default Description
$tier string — Resolved tier slug; empty string when user has no active subscription
$show_id int — ID of the show
$user_id int — WordPress user ID

Returns: string

Example

add_filter( 'benecaster_user_tier_for_show', function( string $tier, int $show_id, int $user_id ): string {
    if ( $tier !== '' ) {
        return $tier; // already has an active token
    }
    // Keep naming a lapsed subscriber's old tier during a grace window. This opens no episodes:
    // give them a standalone grant through benecaster_entitlement_grant_slugs for that.
    $grace_expiry = (int) get_user_meta( $user_id, "_grace_expiry_{$show_id}", true );
    if ( $grace_expiry > time() ) {
        return (string) get_user_meta( $user_id, "_grace_tier_{$show_id}", true );
    }
    return '';
}, 10, 3 );

Notes

Preview as Tier uses this filter so that templates calling benecaster_get_user_tier_for_show() show the previewed tier, and only for the previewing admin: asking about any other user during a preview returns that user's own tier. Do not remove all callbacks unconditionally. Returning a tier slug that does not correspond to a configured tier may cause unexpected behavior in tier-aware template functions.

Affects

  • benecaster_get_user_tier_for_show() function
  • [benecaster_tier_gate] min_tier comparison
  • [benecaster_subscribe] membership panel

Need this built rather than just documented? See our services →