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

suredonation_import_complete Action Hook

Overview

The suredonation_import_complete action fires once when a CSV import session finishes successfully. It is the right hook for anything that needs the whole import in view, final counts, notifications, or a post-import reconciliation pass.

SureDonation Pro uses it to finalize the import-history record and to remap recurring renewal → parent links, which can only be resolved once every row has an ID.

Hook Signature

do_action( 'suredonation_import_complete', $import_id, $progress );

Parameters

  • $import_id _(string)_ – The import session ID.
  • $progress _(array)_ – The final session payload. status is complete and completed_at is set. Also carries created (all created donations and donors IDs), id_map (source ID => new donation ID), donor_map, campaign_map, and the per-phase results counters.

Usage

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

function your_custom_function( $import_id, $progress ) {

// Your custom logic here.

}

Example

add_action( 'suredonation_import_complete', 'mysite_notify_import_finished', 10, 2 );

function mysite_notify_import_finished( $import_id, $progress ) {

$donations = $progress['results']['donations']['imported'] ?? 0;

$donors    = $progress['results']['donors']['imported'] ?? 0;

wp_mail(

get_option( 'admin_email' ),

'Donation import finished',

sprintf( 'Imported %d donation(s) and %d donor(s).', $donations, $donors )

);

}

Notes

Fires from Import_Runner::finish(), after the session is marked complete, the uploaded CSV is deleted, and the payload is persisted. suredonation_import_batch_complete fires immediately before it on the same pass.

It fires only on success. A session that fails is marked failed and returns without reaching this hook, so do not rely on it for cleanup use it for follow-up work.

id_map is the source-row ID to new-donation-ID mapping built across the whole import. It is the only place where cross-row relationships can be resolved, because earlier rows do not yet know the IDs of later ones.

The uploaded CSV has already been deleted by the time this runs, so anything you need from the raw file must be captured earlier.

Related Hooks

  • suredonation_import_session_created
  • suredonation_import_batch_complete
  • suredonation_import_donation_inserted
  • suredonation_import_donor_inserted
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