benecaster_get_user_holdings()
benecaster_get_user_holdings( int $show_id, int $user_id = 0 ): array
What a website visitor holds on a show: the same tiers, buy-ups and standalone purchases the episode page reads to decide what to open. Use it when an add-on decides something for a person on the website, in a wp/v2 response or in a check function of its own.
-
tiersare the visitor’s live membership tiers, in the membership system’s own order, asked of the membership plugin (or built-in membership), never read from the tier saved on their feed token. A member on two levels gets both, and a Tier Mapping change shows at once. Empty for a follower and for a revoked feed. -
buyupsare the buy-ups of this show they hold right now, asbenecaster_get_buyup_slug()returns them. A buy-up ends with the membership it rides on. -
grantsare standalone purchases and grants, including any an add-on supplies through benecaster_entitlement_grant_slugs. They are owned outright, so they survive the end of a membership.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
show_id |
int |
— | Yes | The show (post) ID. |
user_id |
int |
0 |
No | WordPress user ID. Defaults to the current user when 0 or omitted. |
Return Value
Type:
array
[ 'tiers' => [...], 'buyups' => [...], 'grants' => [...] ]. All three keys are always present, each a de-duplicated list of slugs. A signed-out visitor, or an ID that is not a show, gets three empty lists.
Example
$holdings = benecaster_get_user_holdings( $show_id );
$slug = benecaster_get_buyup_slug( $transcripts_buyup_id, $show_id ); // null if not this show's
$show_transcript = [] !== array_intersect( [ 'gold', 'platinum' ], $holdings['tiers'] )
|| ( null !== $slug && in_array( $slug, $holdings['buyups'], true ) );
Notes
Test each part separately. A buy-up or grant slug is not a tier. Passed to
[benecaster_tier_gate] or compared as a tier, it matches nothing, and the buyers are the
ones locked out. For a plain "does this person hold slug X?", search all three lists.
This is the website's answer, not the feed's. It never consults the licence, so on a show
in a licence grace period, or for a listener over the plan's limit, it answers as if nothing
had happened, while their feed carries public episodes only. Inside a feed callback, read the
listener_slugs in the callback's context instead.
public is never in it, because everybody holds it: test for public content separately.
An episode's private access link opens one episode for a signed-out visitor but is not a
holding and is not reflected here.
Preview as Tier applies to the previewing admin only. An admin previewing a tier gets that tier alone, with no buy-ups or grants, which is what the episode page opens for them. Asking about any other user is never affected.
**Callbacks on benecaster_user_tier_for_show are not
read**, just as the episode page ignores them for tiers. [benecaster_tier_gate] does read
that filter, so for a visitor with such a callback the two can differ.
There is no filter on the answer. It is not cached, and each call asks the membership plugin: call it once per request and keep the result.
For whether someone is a member at all, including the answer cannot tell, use
benecaster_user_has_active_membership().
See Decide something on the website from what the visitor holds.
Need this built rather than just documented? See our services →