benecaster_get_user_grants()
benecaster_get_user_grants( int $show_id, int $user_id = 0 ): array
Returns the live grant slugs a person currently holds on a show. A grant is non-tier access — episodes or a bundle owned outright, independent of any membership tier. Episode Sales purchases are the first user of this surface.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
show_id |
int |
— | Yes | The show (post) ID. Required — a grant cannot exist without a show, unlike benecaster_user_has_buyup()'s optional $show_id. |
user_id |
int |
0 |
No | WordPress user ID. Defaults to the current user when 0 or omitted. |
Return Value
Type:
array
The non-tier grant slugs the person currently holds on the show, oldest first — named sets of episodes (a product or a bundle) held outside any membership tier. Empty for a logged-out visitor, an unknown show, or someone holding nothing. Only live grants: expires_at in the future, or NULL for a lifetime grant.
Example
// Everything this listener owns on the show — live grants only.
foreach ( benecaster_get_user_grants( $show_id, $user_id ) as $slug ) {
echo esc_html( $slug ); // your own product names live in your add-on
}
Notes
Returns what the feed serves, not only the rows Benecaster stores. The answer resolves through Entitlement\GrantSlugResolver, so a grant registered by an add-on through the benecaster_entitlement_grant_slugs filter is included. Reading the benecaster_entitlements table directly instead would answer "nothing" on a site whose add-on supplies its own grants, while the listener's feed carried those episodes.
Buy-ups are excluded, deliberately. A buy-up is a recurring subscription item that dies with the membership it rides on; a grant is owned outright and survives an over-limit demotion, a license grace period and the end of the membership. Ask the buy-up question with benecaster_user_has_buyup() instead.
A grant slug is not a tier slug. Feeding one to a tier-shaped API ([benecaster_tier_gate]'s min_tier, or benecaster_get_user_tier_for_show()) fails closed for exactly the people who bought it, silently — the same trap buy-ups carry.
To ask about one named grant rather than fetching the whole list, use benecaster_user_holds_grant() — the direct form of this function and the one to use in a gate. See Gate anything on a listener's episode purchases for the full recipe.
Need this built rather than just documented? See our services →