Run your own code when moving an episode copies its tracked links to the new show
When an episode moves to another show, Outlinks gives each of its tracked references a new tracked link in the destination show, copying the destination, affiliate URL, expiry and country rules. The old show’s link is left as it was. These hooks fire once for each link copied.
benecaster_outlinks_redirect_move_copy_before( int $source_redirect_id, int $episode_id, int $from_show_id, int $to_show_id ): immediately before the new link is created; it has no id yet.benecaster_outlinks_redirect_move_copy_after( int $source_redirect_id, int $new_redirect_id, int $episode_id, int $from_show_id, int $to_show_id ): once the copy is complete, the new link created with a free name (usually{old-name}-2) and its settings and country rules saved.
Nothing fires for a reference whose library item already has a tracked link in the destination show (that one is reused unchanged), for a reference that had no tracked link in the old show, or when the old link’s destination is not http or https (no copy is made). If the new link cannot be created, or its settings cannot be saved and it is removed again, before has fired and after does not.
Code
<?php
add_action( 'benecaster_outlinks_redirect_move_copy_after', function ( int $source_id, int $new_id, int $episode_id, int $from_show_id, int $to_show_id ): void {
error_log( sprintf( 'Episode %d moved to show %d: redirect %d copied as %d', $episode_id, $to_show_id, $source_id, $new_id ) );
}, 10, 5 );
Hooks Used
Need this built rather than just documented? See our services →