Skip to main content

Show transcript-derived results only to people who may see the transcript

Premium Beginner

Your add-on indexes transcript text and shows matches, snippets or answers built from it. A transcript can be limited to tiers, to buy-up holders, or hidden, independently of who can play the episode. Ask benecaster_user_can_see_transcript() before showing anything you built from it; never re-implement the rules from the episode’s settings.

  • Index through benecaster_get_episode_transcript_text() and re-read on benecaster_transcript_updated (Read an episode’s transcript, and react when it changes): a Hidden transcript reads as null, so it never reaches your index, and the action fires with visibility when one becomes Hidden.
  • This answers for a website user. In a podcast feed there is no user: the add-on decides there on the listener’s holdings.
  • Someone who can edit the episode gets true, Hidden included, even under Preview as Tier: a podcaster previewing a tier still sees every transcript. To see what a listener gets, pass a member’s user ID.
  • Pass a user ID to ask about someone other than the current visitor, for example when building an email for them.

Code

<?php
$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
    }
);

View on GitHub →

Hooks Used

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