Skip to main content

benecaster_shadow_records_purged

Action Free

Fires after each nightly shadow record purge run completes. Shadow records are Patreon and Supercast import header rows — they are deleted once they exceed the expiry threshold (default 90 days, configurable via benecaster_shadow_record_expiry_days) to clean up completed migrations.

This hook fires even when $count is zero, meaning no expired records were found in this run. The $count reflects the number of import header rows removed; corresponding patron rows are cascade-deleted automatically as part of the same operation. Check $count > 0 inside your callback if you only want to react to runs that actually deleted records.

Parameters

Name Type Default Description
$count int Number of expired migration imports deleted; each import's patron records are removed with it

Examples

Log purge results to monitoring service

add_action( 'benecaster_shadow_records_purged', function ( int $count ): void {
    if ( $count === 0 ) {
        return;
    }

    my_monitoring_service()->track( 'benecaster.shadow_records_purged', [
        'count' => $count,
    ] );
} );

Notes

This hook fires on every run, including runs where no records were expired. Always guard with a $count > 0 check to avoid unnecessary side-effects on empty runs. The expiry threshold is configurable via the benecaster_shadow_record_expiry_days filter (default 90 days). Increase it if your migration window is longer than 90 days.