benecaster_gdpr_purge_skip
Allows skipping the erasure operation for a specific user before it executes. Fires before each per-user erasure cascade — once per user being processed — from the nightly retention sweep, from deleting a subscriber by email on the Tools screen, and when a WordPress account is deleted. Tools → Erase Personal Data (the WordPress eraser) does not run this cascade. Return true to abort the erasure for this user. The benecaster_before_gdpr_purge action will not fire for skipped users.
On ‘account_deleted’, skipping does not keep the person’s feed: their built-in Stripe subscriptions are already cancelled and their tokens already revoked before this filter runs. It only leaves the revoked rows and the rest of their data in place.
$email is null in the retention sweep, which locates users by ID rather than email. This filter fires per user, so skipping one user does not affect others in the same cron sweep. To abort an entire cron sweep, use benecaster_gdpr_retention_skip.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$skip |
bool |
— | Whether to skip this user. Default false. |
$source |
string |
— | What triggered the erasure: 'cron' (the nightly retention sweep), 'manual' (a subscriber deleted by email from the Tools screen, `POST /tools/gdpr/delete-subscriber`) or 'account_deleted' (the person's WordPress account was deleted). |
$user_id |
int |
— | WordPress user ID being erased; 0 on 'manual' when no WordPress account has that email. |
$email |
?string |
— | Email address being erased. null on 'cron', and on 'account_deleted' when the account had no email. |
Returns:
bool
Examples
Skip erasure for users flagged as legally on hold
add_filter( 'benecaster_gdpr_purge_skip', function ( bool $skip, string $source, int $user_id, ?string $email ): bool {
if ( get_user_meta( $user_id, 'gdpr_legal_hold', true ) ) {
return true;
}
return $skip;
}, 10, 4 );
Notes
Returning true silently aborts the erasure for the given user. No data is deleted and no error is recorded.
Affects
- GDPR per-user erasure cascade
Need this built rather than just documented? See our services →