Skip to main content

benecaster_export_ttl_days

Filter Free

Filters how many days a generated data-export file is kept in wp-content/uploads/benecaster/exports/ before the nightly benecaster_export_ttl_cleanup cron deletes it. Default: 7.

Return 0 to disable auto-deletion entirely — appropriate when retention is managed externally, by a backup system or a compliance process. Negative values clamp to 0.

The BENECASTER_EXPORT_TTL_DAYS constant is read BEFORE this filter and short-circuits it. If that constant is defined in wp-config.php, this filter never runs. The constant is the operator’s hard override; the filter is the developer’s default. If your callback appears to do nothing, check for the constant first — that is the usual explanation.

Fires once per admin Export list request and once per daily cron tick, so it must be cheap.

Parameters

Name Type Default Description
$days int — The current TTL in days. `7` unless already filtered.

Returns: int

Examples

Keep exports for 30 days

add_filter( 'benecaster_export_ttl_days', function ( int $days ): int {
    return 30;
} );

Disable auto-deletion, retaining exports indefinitely

add_filter( 'benecaster_export_ttl_days', function ( int $days ): int {
    // Retention is handled by our backup process; never unlink here.
    return 0;
} );

Notes

Lengthening the TTL keeps personal data on disk for longer. Exports contain subscriber email addresses and token records, so a long retention window is a deliberate privacy decision rather than a convenience one — and it interacts with any retention commitment in your privacy policy.

WP-Cron fires on traffic, so on a quiet site files may outlive the TTL you set here. Treat the value as an intention rather than a guarantee; use a server cron where the timing matters.

The .htaccess and index.php files that guard the exports directory are never deleted, regardless of this value.

Need this built rather than just documented? See our services →