Email Alert for Large Donations (GiveWP)
Emails your fundraising team as soon as a donation at or above a set amount is completed, so major donors can be thanked personally the same day.
Opens WPIDE on
Code
$wpide_threshold = 500; // Amount that triggers the alert.
$wpide_notify_to = get_option( 'admin_email' ); // Recipient(s).
add_action( 'give_complete_donation', function ( $donation_id ) use ( $wpide_threshold, $wpide_notify_to ) {
if ( ! function_exists( 'give_donation_amount' ) ) {
return;
}
$amount = (float) give_donation_amount( $donation_id );
if ( $amount < $wpide_threshold ) {
return;
}
$form_id = function_exists( 'give_get_payment_form_id' ) ? give_get_payment_form_id( $donation_id ) : 0;
$email = function_exists( 'give_get_payment_user_email' ) ? give_get_payment_user_email( $donation_id ) : '';
wp_mail(
$wpide_notify_to,
sprintf( 'Large donation received: %s', html_entity_decode( wp_strip_all_tags( give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ) ) ) ) ),
sprintf(
"Donation #%1\$d\nAmount: %2\$s\nForm: %3\$s\nDonor email: %4\$s\nView: %5\$s\n",
$donation_id,
$amount,
$form_id ? get_the_title( $form_id ) : '-',
$email,
admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . (int) $donation_id )
)
);
} );
Notes
Set $wpide_threshold in your site currency and $wpide_notify_to.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.