Skip to main content

benecaster_transcript_updated

Action Premium transcription

Fires once, after the Transcription Service add-on stores a change to an episode’s transcript, whatever caused it, so one callback catches every source. More precisely, it fires whenever what benecaster_get_episode_transcript_text() returns for the episode changes, not only when the text does.

$reason says why:

  • transcribed: a provider transcription completed.
  • visibility: a visibility change moved the transcript into or out of Hidden, so the reader now returns null, or the text again. The text itself did not change.
  • imported: a transcript imported from a file, paste or feed changed the text.
  • edited: a correction saved in the episode editor changed the text.
  • deleted fires when a transcript is removed with Remove transcript, and only when the reader had an answer, so not for a failed transcript or a Hidden one. After deleted the reader returns null.
  • speakers: a save under Speaker names in the episode editor’s Transcript tab changed which name or guest a speaker is mapped to, for a transcript the readers answer for (not a Hidden one). It fires once. The text did not change, but the speaker labels and guests that benecaster_get_episode_transcript_passages() returns did. A guest renamed in Guest Manager fires nothing, because the label is read live.

Accept values you don’t know: more causes can be added.

For visibility, it fires once per finished transcript of the episode whose own setting changed, or of every episode following a show default that moved into or out of Hidden, after the setting is stored. A change between two settings that are both not Hidden, such as All visitors to Selected tiers, fires nothing, because the reader’s answer is the same. It does not fire when a transcription finishes with the same text the episode already had.

Parameters

Name Type Default Description
$transcript_id int — ID of the transcript that changed
$episode_id int — ID of its episode
$reason string — `transcribed`, `imported`, `edited`, `deleted`, `visibility` or `speakers`. Accept values you do not know.

Examples

Re-index an episode in the background whenever its transcript changes

add_action( 'benecaster_transcript_updated', function ( int $transcript_id, int $episode_id, string $reason ): void {
    as_enqueue_async_action( 'my_addon_reindex_episode', [ $episode_id ], 'my-addon' );
}, 10, 3 );

Notes

It runs inside the request or background job that changed the transcript, so do slow work such as re-indexing in a job of your own. It fires for every transcript, whatever its visibility: before you show anything built from the text, check benecaster_user_can_see_transcript(). Walkthroughs: Read an episode's transcript, and react when it changes and Read a transcript's passages by speaker, with each speaker's guest.

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