benecaster_user_has_buyup()
Required add-on: Core
Returns true if a subscriber holds an active buy-up grant for a given buy-up slug; false otherwise.
Signature
benecaster_user_has_buyup( int $user_id, string $buyup_slug, int $show_id ): bool
Parameters
| Name | Type | Description |
|---|---|---|
$user_id |
int | WordPress user ID of the subscriber to check |
$buyup_slug |
string | The buy-up’s internal slug (set in the buy-up definition) |
$show_id |
int | Show post ID |
Return Value
true when the subscriber has an active (non-expired, non-cancelled) grant for the specified buy-up. false when the grant does not exist, has been cancelled, or has been revoked.
Notes
This function checks the live benecaster_subscriber_buyups table — it is not cached. For high-frequency calls within a single request, cache the result in a local variable.
Grants in a cancelled-but-not-yet-expired state (subscriber cancelled before the period end) still return true — access continues until the Stripe billing period closes.
Example Usage
if ( benecaster_user_has_buyup( get_current_user_id(), 'transcript-archive', $show_id ) ) {
// Show the full transcript
} else {
// Prompt the subscriber to purchase
}
Related
benecaster_buyup_purchased— fires on grant creation- Buy-up Content Gating — per-episode access via buy-up slugs