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 both the nightly retention cron job and the manual REST endpoint delete. Return true to abort the erasure for this user. The benecaster_before_gdpr_purge action will not fire for skipped users.
$email may be null in cron context when the retention job 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' (nightly retention job) or 'manual' (REST endpoint delete). |
$user_id |
int |
— | WordPress user ID being erased. |
$email |
?string |
— | Email address being erased. null when the cron job is processing by user ID only. |
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 →