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

suredonation_import_donation_inserted Action Hook

Overview

The suredonation_import_donation_inserted action fires after an imported donation row is successfully inserted. It gives you the new donation’s ID together with the CSV row it came from, which is what makes post-import reconciliation possible.

SureDonation Pro uses it to track created rows for rollback, and to build the old → new ID mapping it needs to relink recurring renewals once the import completes.

Hook Signature

do_action( 'suredonation_import_donation_inserted', $donation_id, $data, $donation );

Parameters

$donation_id _(int)_ – The new donation’s ID.

$data _(array)_ – The mapped CSV row fields, including any columns the standard mapper ignored.

$donation _(array)_ – The donation data that was inserted, after suredonation_import_donation_row has run.

Usage

add_action( 'suredonation_import_donation_inserted', 'your_custom_function', 10, 3 );

function your_custom_function( $donation_id, $data, $donation ) {

// Your custom logic here.

}

Example

add_action( 'suredonation_import_donation_inserted', 'mysite_store_legacy_id', 10, 3 );

function mysite_store_legacy_id( $donation_id, $data, $donation ) {

if ( empty( $data['legacy_id'] ) ) {

return;

}

// Keep the source system's ID so a later sync can match this record.

update_metadata(

'suredonation_donation',

$donation_id,

'_mysite_legacy_id',

sanitize_text_field( $data['legacy_id'] )

);

}

Fires from Donations_Import_Mapper, only when the insert succeeded — a rejected or skipped row never reaches it.

It does not fire during a dry run. The importer’s analyze/preview pass counts rows without inserting them.

By the time it fires, SureDonation has already updated the donor aggregates and recorded the row in the session’s created list and id_map.

This runs once per imported donation, so a large import calls it thousands of times. Batch or defer anything expensive rather than doing per-row remote calls here.

Custom fields beyond the standard export columns are preserved separately under donation_data[‘fields’] to keep the export/import round trip lossless — read them from $donation rather than re-parsing $data.

Related Hooks

  • suredonation_import_donation_row
  • suredonation_import_donor_inserted
  • suredonation_import_complete
  • suredonation_new_donation
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