Skip to main content

benecaster_episode_note_added

Action Free

Fires after a production note has been saved against an episode. It covers both notes a person typed in the episode editor and notes an add-on wrote programmatically. The note is already stored by the time your callback runs.

Use $note_type to tell human notes ('internal') from generated ones ('system'). A system note always has a null $author_id, so that is the more reliable test of the two.

To write one from your own code, use benecaster_add_episode_note() — this action fires straight after it.

Parameters

Name Type Default Description
$note_id int — ID of the newly inserted note row
$episode_id int — ID of the episode the note belongs to
$show_id int — ID of the show
$author_id int|null — WordPress user ID of the note author, or null for system-generated notes
$content string — Plain text content of the note
$note_type string — Note type: 'internal' (podcaster-written) or 'system' (auto-generated)

Examples

Post human note to Slack channel

add_action( 'benecaster_episode_note_added', function (
    int    $note_id,
    int    $episode_id,
    int    $show_id,
    ?int   $author_id,
    string $content,
    string $note_type
): void {
    if ( 'internal' !== $note_type ) {
        return; // only notify on human notes
    }
    $author  = $author_id ? get_user_by( 'id', $author_id )->display_name : 'Unknown';
    $episode = get_the_title( $episode_id );
    my_slack_notify( '#production', "{$author} added a note to \u201c{$episode}\u201d: {$content}" );
}, 10, 6 );

Sync notes to PM tool

add_action( 'benecaster_episode_note_added', function (
    int    $note_id,
    int    $episode_id,
    int    $show_id,
    ?int   $author_id,
    string $content,
    string $note_type
): void {
    my_pm_tool_add_comment( [
        'episode_id' => $episode_id,
        'author_id'  => $author_id,
        'body'       => $content,
        'is_system'  => 'system' === $note_type,
    ] );
}, 10, 6 );

Notes

Use the $note_type parameter to distinguish user-added notes ('internal') from add-on-generated notes ('system'). System notes always carry a null $author_id. To write system notes from custom code, call benecaster_add_episode_note( $episode_id, $content, 'system' ) — this hook fires immediately after the insert.

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