benecaster_user_can_see_transcript()
benecaster_user_can_see_transcript( int $episode_id, int $user_id = 0 ): bool
Whether a website user may see an episode’s transcript from the Transcription Service add-on, or anything built from it: a search match, a snippet, a summary, an answer quoting it. A transcript can be limited to subscribers, to tiers, to buy-up holders, or hidden, independently of who can play the episode. Ask this before showing anything you built from transcript text, and never re-implement the rules.
-
Someone who can edit the episode gets
truefor everything, Hidden included: it is their own content. -
Anyone else gets the episode’s transcript visibility (its own setting, else the show’s; a show that never chose is All visitors, and a setting that cannot be read is Hidden), decided on what they hold on the show, as benecaster_get_user_holdings() reads it:
- All visitors: everyone, signed out included.
- All subscribers: anyone holding a live tier of the show.
- Selected tiers: anyone holding one of the listed tiers. The tier saved on their feed token is never read.
- Buy-up holders: anyone holding one of the listed buy-ups of the show.
- Hidden: nobody.
Tiers and buy-ups are read apart: a buy-up never satisfies a tier rule, and standalone purchases and grants decide nothing.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
episode_id |
int |
— | Yes | The episode (post) ID. |
user_id |
int |
0 |
No | WordPress user ID. Defaults to the current user when 0 or omitted; a signed-out visitor is the current user 0. |
Return Value
Type:
bool
true when the user may see the episode's transcript, or anything built from it. false for a post that is not an episode, or an episode with no show.
Example
$results = array_filter(
$results, // each with an episode_id, from your own transcript index
static function ( array $hit ): bool {
if ( ! function_exists( 'benecaster_user_can_see_transcript' ) ) {
return false; // No Transcription Service: no transcript text should be in your index either.
}
return benecaster_user_can_see_transcript( (int) $hit['episode_id'] ); // the current visitor
}
);
Hooks Fired
Notes
The editor rule answers first, even under Preview as Tier. A podcaster previewing a tier
still gets true for every transcript. To see what a listener gets, pass that member's user
ID.
This is the website's answer. The add-on uses it for the transcript's address in the
episode's wp/v2 response and for the episode page's Read the transcript link, so the
three never disagree. Podcast feeds and site search do not ask it: they have no user, and
decide on the listener's holdings by the same rules.
The answer is filtered by benecaster_user_can_see_transcript, which has the last word.
A Hidden transcript is never returned by benecaster_get_episode_transcript_text() at all, so an index built from it holds none, editor or not.
There is no licence check: a show whose licence lapsed, or that switched Transcription off,
keeps its rules. It is defined on every request. Guard calls with function_exists(), since
Transcription Service may not be installed; without it, there is no transcript to protect.
See Show transcript-derived results only to people who may see the transcript.
Need this built rather than just documented? See our services →