Read or save an episode’s Guest preparation, and run code when it is saved
The Workbench’s Guest preparation tile (id guest-preparation, Pre-production, priority 30, off by default) keeps two things on the episode: whether the guests are prepared (a Guest preparation complete box) and freeform notes.
With Guest Manager on for the episode’s show, the tile lists the episode’s guests through Guest Manager’s readers (see Read an episode’s guests from another add-on and Read one guest by id from another add-on), each linked to their record, with an Edit guests button to the episode editor’s Guests tab. It never links, unlinks or orders guests: use Link, unlink or reorder an episode’s guests from code, as the episode editor’s selector does. Without Guest Manager, or with it off for the show, the tile is a notes field.
- Reading:
GET …/episodes/{episode_id}/workbench(see Read the Podcast Workflow Workbench over REST) carriesworkflow.guest_preparation:{ guest_manager, guests: [ { id, name, record_url } ], prepared, notes, edit_guests_url }.guestsis[]while Guest Manager is off.notesis returned either way, and kept while Guest Manager is on.record_urlis Guest Manager’sedit_urlfor the guest, or''. - Saving:
PUT /benecaster-podcast-workflow/v1/shows/{show_id}/episodes/{episode_id}/guest-preparationwith{ prepared: bool, notes: string }, both every time (the whole state, not a patch). Notes are plain text: tags stripped, line breaks kept, ends trimmed. More than 10,000 characters is400 benecaster_podcast_workflow_guest_notes_too_long; a missing or mistyped field is400 benecaster_podcast_workflow_invalid_field. The Workbench’s per-show checks apply. It answers the refreshed canvas and writes no episode note. - The tile’s state: Done once the box is ticked; otherwise In progress with a guest linked (Guest Manager on) or notes written (off); Not started before that.
countis the number of guests while Guest Manager is on. - The tile is declared with no
add_on, unlike a partner add-on’s tile, because it has a state (the notes) while Guest Manager is off, and a tile whoseadd_onis off is never asked for one. - benecaster_podcast_workflow_before_save_guest_preparation and benecaster_podcast_workflow_after_save_guest_preparation are actions,
( int $episode_id, bool $prepared, string $notes, int $show_id ), around every save, with the notes as stored.
Code
<?php
// Tell the host when a guest is ready.
add_action( 'benecaster_podcast_workflow_after_save_guest_preparation', function ( int $episode_id, bool $prepared, string $notes, int $show_id ): void {
if ( $prepared ) {
my_plugin_notify_host( $episode_id );
}
}, 10, 4 );
Hooks Used
Need this built rather than just documented? See our services →