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.
When to Use This
When a podcaster sets up an RSS redirect with a 6-month or 1-year duration, Benecaster automatically removes the itunes:new-feed-url tag from the feed after that period. Use this hook to:
-
Notify the show owner that their feed redirect has expired and is no longer active
-
Log the expiry to an analytics or audit system
-
Trigger a cache clear or external notification
How It Works
The action passes a count of how many redirect tags were removed and an array of the affected show IDs. Bail early when the count is zero, then loop the show IDs and do your per-show work — reading the owner’s email from post meta and sending a notification is the common case.
Notes
The action fires even when the count is zero. Guard on it to avoid unnecessary work on days when no redirect tags expire. The hook always fires as part of the daily cron job — it is not conditional on whether any expiries occurred.
Permanent redirects never expire. Shows configured with a Permanent duration never appear in the show ID array. The tag remains in the feed indefinitely until the podcaster removes it manually via Settings → Show.
The feed cache is already invalidated. By the time this hook fires, Benecaster has already cleared the feed cache for the affected shows. You do not need to clear it in your callback.
The action fires at most once per day. The daily WP-Cron job runs once per calendar day. If multiple shows expire on the same day, they are all included in a single array.
Related
-
Setup Wizard Walkthrough — how the migration redirect step works during setup
-
Show Settings Reference — manually removing or changing the redirect
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 ) {
benecaster_mail(
$show_id,
$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 );
Hooks Used
Need this built rather than just documented? See our services →