Skip to content

Privacy, Consents & Retention

Contacts provides built-in GDPR tooling that protects both individual privacy and relational data integrity across your entire ProcessWire ecosystem.

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:

  1. Wipes personal fields, roles, tags, primary_organization, owner_user_id, linked_user_id, source, avatar, channels, addresses, memberships, and consents.
  2. Scrubs linked contacts-notes bodies and follow-up metadata in closed-cursor ID batches (getMany()/saveMany()).
  3. Purges entries_history revision and draft snapshots via Entries::historyManager()->deleteItemHistory().
  4. Redacts entries_history kind = 'log' activity rows (redactActivityLogs()).
  5. Records immutable gdpr_anonymized_at and sets EntryItem::STATUS_PUBLISHED | EntryItem::STATUS_UNPUBLISHED | EntryItem::STATUS_LOCKED.
  6. Fires Contacts::afterAnonymize($contact, $reason) and emits the contacts.contact.anonymized webhook 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: ContactsRetentionTask runs daily at 03:00 via processwire-console (schedule:run).
  • Manual / CLI Execution:
Terminal window
# Preview eligible contacts without mutating anything
php vendor/bin/wire contacts:retention --action=anonymize --days=730 --dry-run --json
# Archive or anonymize stale records
php vendor/bin/wire contacts:retention --action=archive --days=365 --limit=500 --force --json

Next steps