React when a show’s redirect tag is automatically removed
The daily cron removes expired itunes:new-feed-url redirect tags automatically. benecaster_redirect_expiry_run fires once per run with the count and affected show IDs. Use to notify show owners, update an external record, or log the expiry event. Guard with if ( $count === 0 ) { return; } — the action fires even when nothing expired.
Code
<?php
add_action( 'benecaster_redirect_expiry_run', function ( int $count, array $show_ids ): void {
if ( $count === 0 ) {
return;
}
foreach ( $show_ids as $show_id ) {
$owner_email = get_post_meta( $show_id, '_benecaster_show_author_email', true );
if ( $owner_email ) {
wp_mail(
$owner_email,
sprintf( __( 'Feed redirect for "%s" has expired', 'my-addon' ), get_the_title( $show_id ) ),
__( 'Your <itunes:new-feed-url> redirect tag has been removed from your podcast feed.', 'my-addon' )
);
}
}
}, 10, 2 );