Programmatically stamp a credit on episode save
Auto-apply the default credit template when a new episode is created so the podcaster never has to click Apply manually. Uses benecaster_apply_default_credit() — the public helper that resolves the correct template via benecaster_credit_options, runs the stamp, and fires benecaster_credit_applied on success. Also includes a WP-CLI batch approach for retroactively stamping existing episodes.
Code
<?php
/**
* Auto-apply the show's default credit when a new episode is created.
* Respects the benecaster_credit_options filter — if an add-on pre-selects
* a different template for this episode, that template is applied.
*/
add_action(
'benecaster_episode_created',
function ( int $episode_id, int $show_id ): void {
$episode = get_post( $episode_id );
if ( ! $episode || ! in_array( $episode->post_status, [ 'draft', 'publish' ], true ) ) {
return;
}
benecaster_apply_default_credit( $episode_id );
},
10,
2
);