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

suredonation_donation_completed Action Hook

Overview

The suredonation_donation_completed action fires when a donation’s payment reaches the completed state. It fires exactly once per genuine completion, making it the recommended hook for fulfilment logic such as granting access, sending a thank-you, or syncing a paid donation to an external system.

Hook Signature

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

Parameters

  • $donation_id _(int)_ – The completed donation’s ID.
  • $payload _(array)_ – The curated, integration-safe donation payload from Donations::get_integration_payload(), reflecting the donation state at completion. See suredonation_donation_created for the full key list.

Usage

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

function your_custom_function( $donation_id, $payload ) {

    // Your custom logic here.

}

Example

add_action( 'suredonation_donation_completed', 'mysite_grant_membership', 10, 2 );

function mysite_grant_membership( $donation_id, $payload ) {

    if ( empty( $payload['donor_email'] ) ) {

        return;

    }

    $user = get_user_by( 'email', $payload['donor_email'] );

    if ( $user ) {

        $user->add_role( 'supporter' );

    }

}

Related Hooks

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