Privacy, Consents & Retention
Contacts provides built-in GDPR tooling that protects both individual privacy and relational data integrity across your entire ProcessWire ecosystem.
Purpose-Scoped Consent Ledger (ConsentPurpose)
Section titled “Purpose-Scoped Consent Ledger (ConsentPurpose)”Rather than relying on a single boolean flag, Contacts stores an append-only audit trail in contacts-consent blocks across five canonical purposes (Totoglu\Contacts\Domain\ConsentPurpose):
marketing_email(ConsentPurpose::MarketingEmail)marketing_sms(ConsentPurpose::MarketingSms)marketing_phone(ConsentPurpose::MarketingPhone)profiling(ConsentPurpose::Profiling)third_party_sharing(ConsentPurpose::ThirdPartySharing)
<?php
declare(strict_types=1);
namespace ProcessWire;
use Totoglu\Contacts\Domain\ConsentPurpose;
$contacts = Contacts::requireInstance($this);
// Append a timestamped consent decision with source and policy version$contacts->recordConsent($contact, ConsentPurpose::MarketingEmail, true, [ 'source' => 'broker_onboarding', 'evidence' => 'privacy-policy-2026-v1',]);
// Query latest consent state or full history$allowed = $contacts->hasConsent($contact, ConsentPurpose::MarketingEmail);$history = $contacts->consentHistory($contact, ConsentPurpose::MarketingEmail);GDPR Subject Data Export (exportSubjectData)
Section titled “GDPR Subject Data Export (exportSubjectData)”Generate a complete JSON privacy bundle from ContactActionBar -> GDPR Export (./export/?id={uuid}&privacy=1), Headless GET /api/v1/contacts/{id}/privacy-export, or PHP:
<?php
declare(strict_types=1);
namespace ProcessWire;
$contacts = Contacts::requireInstance($this);$bundle = $contacts->exportSubjectData($contact);ContactPrivacyService::exportSubjectData() streams all linked notes via findMany(), includes the full consents ledger, and invokes Contacts::collectSubjectData so every installed 'contactsParticipant' => true module appends its own subject records to $payload['modules'][...].
UUID-Preserving GDPR Erasure (anonymizeContact)
Section titled “UUID-Preserving GDPR Erasure (anonymizeContact)”Deleting a contact row breaks invoices, bookings, and historical analytics. Instead, anonymizeContact() executes inside Contacts::runInTransaction() with Entries::getForUpdate() locking and preserves the contact UUID while erasing all PII:
- Wipes personal fields,
roles,tags,primary_organization,owner_user_id,linked_user_id,source,avatar, channels, addresses, memberships, and consents. - Scrubs linked
contacts-notesbodies and follow-up metadata in closed-cursor ID batches (getMany()/saveMany()). - Purges
entries_historyrevisionanddraftsnapshots viaEntries::historyManager()->deleteItemHistory(). - Redacts
entries_historykind = 'log'activity rows (redactActivityLogs()). - Records immutable
gdpr_anonymized_atand setsEntryItem::STATUS_PUBLISHED | EntryItem::STATUS_UNPUBLISHED | EntryItem::STATUS_LOCKED. - Fires
Contacts::afterAnonymize($contact, $reason)and emits thecontacts.contact.anonymizedwebhook post-commit.
<?php
declare(strict_types=1);
namespace ProcessWire;
$contacts = Contacts::requireInstance($this);$anonymized = $contacts->anonymizeContact($contact, 'GDPR Article 17 erasure request');Linked User Deletion Cleanup (handleDeletedUser)
Section titled “Linked User Deletion Cleanup (handleDeletedUser)”Because Contacts declares 'entriesUserDeleteListener' => true, deleting a ProcessWire User triggers Contacts::handleDeletedUser($userId) automatically, unlinking or anonymizing matching non-anonymized contacts in 200-item chunks according to account_anonymize_on_delete in Settings.
Automated Retention Policy (ContactRetentionService & ContactsRetentionTask)
Section titled “Automated Retention Policy (ContactRetentionService & ContactsRetentionTask)”Set Retention (Days) (retention_days > 0) under Setup -> Contacts -> Settings -> Privacy & Sync to automatically evaluate inactive or archived contacts whose modified timestamp and latest interaction occurred_at precede the cutoff.
- Scheduled Task:
ContactsRetentionTaskruns daily at03:00viaprocesswire-console(schedule:run). - Manual / CLI Execution:
# Preview eligible contacts without mutating anythingphp vendor/bin/wire contacts:retention --action=anonymize --days=730 --dry-run --json
# Archive or anonymize stale recordsphp vendor/bin/wire contacts:retention --action=archive --days=365 --limit=500 --force --json