Skip to main content

benecaster_user_can_see_transcript

Filter Premium transcription

Has the last word on whether a website user may see an episode’s transcript: the answer benecaster_user_can_see_transcript() returns, whether the transcript’s address is included in the episode’s wp/v2 response, and whether the episode page’s Read the transcript link shows.

$can is the Transcription Service add-on’s answer: true for anyone who can edit the episode, Hidden included, and otherwise the episode’s transcript visibility (its own setting, else the show’s) applied to what the user holds on the show.

For the episode page’s link, Benecaster also applies its own access check, so returning true never shows the link to someone who cannot open the episode. Where the add-on shows the transcript on the episode page itself, the link is hidden whatever this returns, so the same transcript is not offered twice.

It does not change podcast feeds or site search. They have no user, and decide on the listener’s holdings by the same rules. It is not asked for a post that is not an episode, or for an episode with no show: the answer there is always false.

Parameters

Name Type Default Description
$can bool — The add-on's answer
$episode_id int — ID of the episode
$user_id int — The user asked about, with the current user already resolved; 0 for a signed-out visitor

Returns: bool

Example

add_filter( 'benecaster_user_can_see_transcript', function ( bool $can, int $episode_id, int $user_id ): bool {
    // Staff accounts read every transcript, whatever its setting.
    return $can || ( $user_id > 0 && user_can( $user_id, 'my_plugin_read_transcripts' ) );
}, 10, 3 );

Notes

Widen with care. Returning true hands that viewer the transcript's permanent public address through wp/v2, and lets other add-ons, such as AI Search, show them transcript text. Walkthrough: Show transcript-derived results only to people who may see the transcript.

Need this built rather than just documented? See our services →