Skip to main content

Clean up external records when a donor requests data erasure

Free Beginner

If you store donor information in an external system — a CRM, a mailing list, or your own database — you need to remove it there when a donor’s data is erased. Benecaster handles its own records: it anonymises the donor’s donation records — name, email, message and the rest of their identity cleared, the financial record (amount, currency, date) kept — and no record is deleted. This hook fires straight after, so you can mirror the erasure in any connected system.

This is the right hook if you need to demonstrate GDPR compliance across your full data footprint, not just the records Benecaster holds directly.

Anyone asks for erasure the same way, through [benecaster_erasure_request] or the Erase my data section of [benecaster_account]. WordPress emails its own confirmation link, and the confirmed request waits under Tools → Erase Personal Data for an administrator.

The hook fires from two places: an administrator completing that request, and the deletion of the donor’s WordPress account. It does not fire for routine data retention sweeps. It fires even when the donor had no donation records, so the count it passes (named $deleted, though nothing is deleted — it is the number of records anonymised) can be 0; check it before calling an external service.

Code

<?php
add_action( 'benecaster_donor_data_erased', function ( string $email, int $deleted ): void {
    if ( $deleted > 0 ) {
        my_crm_purge_contact( $email );
    }
}, 10, 2 );

View on GitHub →

Hooks Used

Need this built rather than just documented? See our services →