benecaster_user_has_buyup()
Checks whether a subscriber has bought a particular buy-up on a particular show. Use it to gate anything a buy-up is meant to unlock.
This function is the whole of Benecaster’s non-episode buy-up gating, and that is worth being plain about. Episodes have a built-in path — tick the buy-up on the episode’s Access tab and it gates the page and the feed with no code. Everything else a buy-up might unlock — a transcript, a downloads area, a members-only page, a template part — has no admin surface and is not planned to get one. It is this function, called in a theme or add-on, and there is no route to it that does not involve writing PHP. Say so when you scope the work, rather than leaving a podcaster to discover it after they have sold the buy-up.
This reads live rather than from a cache, so the answer is always current — but if you are asking repeatedly in one request, hold the result in a variable rather than calling it in a loop.
The show comes from the buy-up, not from the grant. A buy-up belongs to exactly one show, and passing $show_id asks whether the grant unlocks content on that show — answered from the buy-up’s own record. Do not match on the grant row’s own copy of the show — it is denormalised from whichever show the purchase came through, so it can disagree with the buy-up, and matching on it would let a grant earned on one show unlock another show’s content.
Omitting $show_id is not a loophole. It applies no show predicate, but naming a buy-up already names its show, so the answer is the same either way.
Two cases fall back to the grant’s recorded show, deliberately: a buy-up left unassigned by the upgrade on a multi-show install, and one whose definition has since been deleted. Paid access is not revoked over a data-repair state — the lookup is a LEFT join for exactly this reason.
The same rules govern the buy-up branch of benecaster_user_can_access_episode().
See Buy-up content gating for gating episodes by buy-up without writing any of this yourself, and benecaster_buyup_purchased to react when one is bought.