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

suredonation_donation_status_changed Action Hook

Overview

The suredonation_donation_status_changed action fires whenever an update changes a donation’s payment_status to a value different from what it held before the write — for example, a webhook completing a pending donation, or a cancellation. It gives you both the new and old status so you can react to specific transitions.

Hook Signature

do_action( 'suredonation_donation_status_changed', $donation_id, $new_status, $old_status, $payload );

Parameters

  • $donation_id _(int)_ – The updated donation’s ID.
  • $new_status _(string)_ – The new payment status just written (e.g. completed, refunded, failed).
  • $old_status _(string)_ – The previous payment status, captured before the write. An empty string if the prior row could not be read.
  • $payload _(array)_ – The curated, integration-safe donation payload from Donations::get_integration_payload(), reflecting the post-update state. See suredonation_donation_created for the full key list.

Usage

add_action( 'suredonation_donation_status_changed', 'your_custom_function', 10, 4 );

function your_custom_function( $donation_id, $new_status, $old_status, $payload ) {

    // Your custom logic here.

}

Example

add_action( 'suredonation_donation_status_changed', 'mysite_on_failed_payment', 10, 4 );

function mysite_on_failed_payment( $donation_id, $new_status, $old_status, $payload ) {

    if ( 'failed' === $new_status && 'pending' === $old_status ) {

        // A pending donation just failed — flag it for follow-up.

        do_something_with_failed_donation( $donation_id, $payload );

    }

}

Related Hooks

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