benecaster_gdpr_purge_skip
Allows skipping the erasure operation for a specific user before it executes.
When It Fires
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 specific user. The benecaster_before_gdpr_purge action will not fire for users that are skipped.
Parameters
| Name | Type | 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. |
Notes
- Returning
truesilently aborts the erasure for the given user. No data is deleted and no error is recorded. $emailmay benullin cron context when the retention job locates users by ID rather than email. Check before using it.- This filter fires per user, so conditionally skipping one user does not affect others in the same cron sweep.
- To abort an entire cron sweep rather than a single user, use
benecaster_gdpr_retention_skip.
Example Usage
add_filter( 'benecaster_gdpr_purge_skip', function ( bool $skip, string $source, int $user_id, ?string $email ): bool {
// Skip erasure for users flagged as legally on hold
if ( get_user_meta( $user_id, 'gdpr_legal_hold', true ) ) {
return true;
}
return $skip;
}, 10, 4 );
Related Hooks
benecaster_gdpr_retention_skip— aborts the entire nightly cron sweep rather than a single user- [
benecaster_before_gdpr_purge](/docs/benecaster_before_gdpr_purge/) — fires just before the erasure cascade executes for an allowed user - [
benecaster_after_gdpr_purge](/docs/benecaster_after_gdpr_purge/) — fires after the erasure cascade completes