Skip to main content

benecaster_get_buyup_slug()

Membership Free
benecaster_get_buyup_slug( int $buyup_id, int $show_id ): ?string

Turns a buy-up’s ID into the slug the feed knows it by. Settings and benecaster_user_has_buyup() work with a buy-up’s ID, while the feed’s listener holdings ($context['listener_slugs'] in benecaster_feed_podcast_episode_tags) and [benecaster_access_gate buyup="…"] work with its slug. This is the bridge between the two.

Parameters

Name Type Default Required Description
$buyup_id int — Yes The buy-up's ID, as shown in Memberships → Buy-ups and taken by benecaster_user_has_buyup().
$show_id int — Yes The show the buy-up must belong to. Required.

Return Value

Type: ?string

The buy-up's feed slug, or null when the buy-up doesn't exist, belongs to another show, or either ID is 0 or less.

Example

$slug = benecaster_get_buyup_slug( $my_transcripts_buyup_id, $show_id );
if ( null !== $slug && in_array( $slug, $context['listener_slugs'], true ) ) {
    // This listener holds the buy-up.
}

Notes

A buy-up from another show reads as null, the same as one that doesn't exist. That is deliberate: matching another show's slug would let a rule on this show be satisfied by a purchase made on that one. Treat null as "nobody holds it" and withhold whatever you were gating.

An inactive buy-up still returns its slug, because its existing holders' feeds still carry it.

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