benecaster_episode_note_added
Fires after a production note is successfully inserted into the benecaster_episode_notes table. This hook fires for both internal notes added by a user in the episode editor and system notes written programmatically by add-ons via benecaster_add_episode_note(). The note row is already committed to the database when the hook fires.
Use the $note_type parameter to distinguish human notes ('internal') from automatically generated ones ('system'). System notes always have a null $author_id. To write system notes from custom code, call benecaster_add_episode_note( $episode_id, $content, 'system' ) — this action fires immediately after the insert.
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.