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

suredonation_new_donation Action Hook

Overview

The suredonation_new_donation action fires immediately after a brand-new donation is registered, on the same code path as suredonation_donation_created. It is kept as a separate, dedicated hook because the OttoKit (formerly SureTriggers) “New Donation” trigger listens on this specific name. Use it when you want to react to every new donation being created.

Hook Signature

do_action( 'suredonation_new_donation', $donation_id, $payload );

Parameters

  • $donation_id _(int)_ – The newly created donation’s ID.
  • $payload _(array)_ – The curated, integration-safe donation payload from Donations::get_integration_payload(). It is identical to the payload passed to suredonation_donation_created, see that page for the full key list.

Usage

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

function your_custom_function( $donation_id, $payload ) {

    // Your custom logic here.

}

Example

add_action( 'suredonation_new_donation', 'mysite_notify_slack', 10, 2 );

function mysite_notify_slack( $donation_id, $payload ) {

    wp_remote_post( 'https://hooks.slack.com/services/XXX/YYY/ZZZ', [

        'body' => wp_json_encode( [

            'text' => sprintf(

                '🎉 New donation of %s %.2f from %s',

                $payload['currency'],

                $payload['amount'],

                $payload['is_anonymous'] ? 'an anonymous donor' : $payload['donor_name']

            ),

        ] ),

    ] );

}

Fires inside Donations::add() right after suredonation_donation_created, under the same successful-insert condition.

Does not fire for imported/migrated records (skipped when import_source is set).

Fires for every new donation regardless of payment status.

Related Hooks

  • suredonation_donation_created
  • suredonation_donation_completed
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