benecaster_email_log_retention_days
Filters how many days Benecaster keeps the email log and the stored copy of each email it has sent. The default is 180 days; a value below 1 keeps everything.
A daily job deletes email log rows, and sent or failed emails’ stored copies, once they are older than this. Emails still waiting to send are never deleted. The same value is how far back a resend can reach, because the stored copy is what gets re-sent; read it with benecaster_get_email_log_retention_days() rather than applying this filter yourself. Older log rows also show as cleanable in Benecaster → Settings → Tools → Maintenance. The unsubscribe log is never subject to this window.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$days |
int |
— | Retention period in days; default 180 |
Returns:
int
Examples
Extend retention to two years
add_filter( 'benecaster_email_log_retention_days', function( $days ) {
// Extend log retention to 730 days (2 years) for compliance.
return 730;
} );
Reduce retention for high-volume show
add_filter( 'benecaster_email_log_retention_days', function ( int $days ): int {
return 90;
} );
Notes
Shortening the window deletes data at the next daily run. A callback returning 0 keeps everything — it does not mean "delete immediately". The unsubscribe log is never subject to this policy.
Affects
- Email log retention cron
Need this built rather than just documented? See our services →