|
/ Documentation /Developer Hooks & Events/ suredonation_import_donor_inserted Action Hook

suredonation_import_donor_inserted Action Hook

Overview

The suredonation_import_donor_inserted action fires after an imported donor is created. SureDonation Pro uses it to track created donors so an import can be rolled back.

It fires from both import paths that can create a donor: the donors CSV import, and the donations CSV import when a row references a donor who does not exist yet.

Hook Signature

do_action( 'suredonation_import_donor_inserted', $donor_id, $email );

Parameters

$donor_id _(int)_ – The new donor’s ID.

$email _(string)_ – The donor’s email address, which is the key the importer de-duplicates on.

Usage

add_action( 'suredonation_import_donor_inserted', 'your_custom_function', 10, 2 );

function your_custom_function( $donor_id, $email ) {

// Your custom logic here.

}

Example

add_action( 'suredonation_import_donor_inserted', 'mysite_tag_imported_donor', 10, 2 );

function mysite_tag_imported_donor( $donor_id, $email ) {

// Record which donors arrived by import rather than through a donation.

$imported   = get_option( 'mysite_imported_donor_ids', [] );

$imported[] = $donor_id;

update_option( 'mysite_imported_donor_ids', array_unique( $imported ), false );

}

Fires from Donors_Import_Mapper and from Donations_Import_Mapper, in both cases only after Donors::add() returns a valid ID.

It fires only for newly created donors. When the importer matches an existing donor by email it updates that record and increments the donors_matched counter instead, no action is dispatched, which is what keeps a re-import from corrupting existing donors.

It does not fire during a dry run.

If a donor already exists as a WordPress user with the same email, the importer links the records by setting user_id before the insert, so the linkage is already in place when this hook runs.

Related Hooks

  • suredonation_import_donation_inserted
  • suredonation_import_complete
  • suredonation_donor_user_created
  • suredonation_new_donor_user_data
Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Table of Contents
Scroll to Top