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

suredonation_import_session_created Action Hook

Overview

The suredonation_import_session_created action fires when a CSV import session is created, before the first batch runs. It is the earliest point at which an extension can attach to an import. SureDonation Pro uses it to open an import-history record that later batches update.

Hook Signature

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

Parameters

$import_id _(string)_ – The import session ID.

$progress _(array)_ – The session payload. Keys include entity, phases, current_phase, offset, byte_offset, total_rows, donor_map, campaign_map, id_map, created (arrays of created donations and donors IDs), status, and results.

Usage

add_action( 'suredonation_import_session_created', 'your_custom_function', 10, 2 );
function your_custom_function( $import_id, $progress ) {
// Your custom logic here.
}

Example

add_action( 'suredonation_import_session_created', 'mysite_log_import_start', 10, 2 );
function mysite_log_import_start( $import_id, $progress ) {
update_option(
'mysite_last_import',
[
'id'         => $import_id,
'entity'     => $progress['entity'] ?? '',
'total_rows' => $progress['total_rows'] ?? 0,
'started_at' => current_time( 'mysql', true ),
],
false
);
}

Fires once per session, from Import_Runner, immediately after the session payload is first persisted.

At this point status is running and no rows have been imported yet; created is empty and the result counters are all zero. If you need the final counts, use suredonation_import_complete instead.

The session payload is re-persisted after every batch, so anything you store here should be keyed by $import_id rather than assumed to be the only import in flight.

Related Hooks

  • suredonation_import_batch_complete
  • suredonation_import_complete
  • suredonation_import_givewp_session_created
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