benecaster_after_gdpr_purge
Fires after a per-user GDPR erasure cascade completes, with deletion counts for each affected table. Fires from both the nightly retention cron job and the manual REST endpoint delete path. Does not fire for users whose erasure was aborted by the `benecaster_gdpr_purge_skip` filter.
Use this hook to mirror the purge to external systems — CRM contact deletion, email service provider unsubscribe, data warehouse row tombstoning — log completion for compliance audits, or trigger a downstream verification job.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$source |
string |
— | Origin of the purge: 'admin' or 'cron' — matches the paired benecaster_before_gdpr_purge |
$result |
array |
— | Purge result: {deleted_by_table: {table_name: rows_deleted}, total_deleted: int, user_id: int, email: string} |
Examples
Log erasure for GDPR compliance records
add_action( 'benecaster_after_gdpr_purge', function ( string $source, array $result ): void {
$log_entry = sprintf(
'[GDPR] Erasure complete — source=%s user_id=%d email=%s tokens=%d downloads=%d emails=%d patrons=%d',
$source,
$result['user_id'],
$result['email'] ?? 'n/a',
$result['tables']['benecaster_tokens'],
$result['tables']['benecaster_download_log'],
$result['tables']['benecaster_email_log'],
$result['tables']['benecaster_migration_patrons']
);
error_log( $log_entry );
}, 10, 2 );
Notes
All deletions have already been committed when this action fires — it is an observation point, not an opportunity to prevent the erasure. A table count of 0 means no rows matched that user in that table, which is expected for users who never triggered activity there. Use this hook for GDPR compliance records and external system notifications.