Adjust or Disable Export File Auto-Deletion
Data exports contain subscriber email addresses and token records, so Benecaster does not keep them lying around: a nightly sweep deletes any export file older than seven days. The file that stops the exports folder being browsable from the web is never touched.
Seven days is not right for everyone, and there are two ways to change it.
-
A setting in
wp-config.php— the operator’s own decision, and it wins. It is read
before anything else, so an add-on cannot lengthen a retention window the site owner has deliberately shortened. That ordering is the point of having two mechanisms. -
A filter — for an add-on or a site’s own code to adjust the default, within whatever the
operator allows.
Setting the window to zero switches auto-deletion off entirely, and the admin Export list then labels files as retained rather than counting down to their deletion, so nobody is misled about what will happen.
Lengthening the window is a privacy decision, not just a convenience one. Exports contain subscriber email addresses and token records, so a longer TTL means holding personal data longer and may interact with your published retention policy.
Code
<?php
// wp-config.php — hard override to 30 days for a site that generates
// large monthly exports and wants to keep the last two on disk.
define( 'BENECASTER_EXPORT_TTL_DAYS', 30 );
// mu-plugins — per-site policy toggle, e.g. disable when the site's
// backup solution already snapshots the uploads directory nightly.
add_filter( 'benecaster_export_ttl_days', function ( int $days ): int {
return defined( 'MY_SITE_HAS_EXTERNAL_BACKUP' ) && MY_SITE_HAS_EXTERNAL_BACKUP
? 0
: $days;
} );
Hooks Used
Need this built rather than just documented? See our services →