benecaster_user_can_access_episode()
benecaster_user_can_access_episode( int $episode_id, int $show_id, int $user_id = 0 ): bool
Returns whether a user can open a specific episode on the website right now. The episode’s tier dates decide it, the same dates that decide what each podcast feed carries.
Signed out, the episode opens only when its date for the public tier (slug public) has passed: exactly what the public feed carries.
Signed in, it opens when any of these is true, checked in this order:
- the user holds one of the buy-ups the episode requires;
- their active subscription’s tier has an access date for the episode that has passed;
- something they own outright on the show (an episode or bundle bought on its own) has an access
date for the episode that has passed; - the episode’s public date has passed. A member never sees less than a stranger.
An episode with no access dates at all opens for nobody. The check for something owned outright needs no active subscription: it outlives the membership, so a lapsed member who bought episodes can still play them on the episode page, the same as in their podcast app. A future date on every route means false.
Every website surface that locks an episode asks this function: the episode page, the episode archive and show episode list, the episode shortcodes, and the download and transcript links. It does not check the license.
The result passes through benecaster_episode_is_accessible, which has the last word. The filter’s $user_id is the resolved user (the current user when you pass 0), and its $tier_slug is the active subscription’s tier, '' when there is none, even if something else opened the episode. A signed-out visitor holding an episode magic link for this episode (see benecaster_get_episode_access_url()) is answered through that filter as the link’s subscriber, for that one episode only.
The primary access-check function for content gating in theme templates.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
episode_id |
int |
— | Yes | The episode (post) ID. |
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:
bool
true when the episode's public date has passed, or, for a signed-in user, when they hold one of its required buy-ups or their active tier or anything they own outright on the show has an access date for it that has passed. Passed through benecaster_episode_is_accessible.
Example
if ( benecaster_user_can_access_episode( $episode_id, $show_id ) ) {
// render full episode
} else {
// render locked state
}
Hooks Fired
Need this built rather than just documented? See our services →