|
/ Documentation /Developer Hooks & Events/ suredonation_default_email_notifications Filter Hook

suredonation_default_email_notifications Filter Hook

Overview

The suredonation_default_email_notifications filter allows developers to customize the default email notification templates provided by SureDonation.

You can use this filter to:

  • Add custom email notifications.
  • Modify existing default notifications.
  • Create custom donor or administrator emails.
  • Add notifications for custom donation events.
  • Extend the default notification system for an add-on or Pro feature.

SureDonation Pro uses this filter to add subscription-related email notifications.

When to Use This Filter

Use this filter when your extension needs to provide additional email notifications without modifying SureDonation core files.

For example, an extension could add:

  • A custom donor thank-you email.
  • An administrator notification.
  • A notification for a custom payment event.
  • Subscription-related notifications.
  • Custom email templates with SureDonation smart tags.

Filter Signature

apply_filters( 'suredonation_default_email_notifications', $defaults );

Parameters

ParameterTypeDescription
$defaultsarrayThe default email notification configurations.

Each notification can contain properties such as:

KeyTypeDescription
idintUnique notification ID.
statusboolWhether the notification is enabled.
namestringNotification name displayed in the admin area.
email_tostringRecipient email address or smart tag.
subjectstringEmail subject.
email_bodystringEmail body content.
from_namestringSender name.
from_emailstringSender email address.
reply_tostringReply-to email address.
triggerstringEvent that triggers the notification.

Common triggers include:

  • donation_completed
  • donation_failed
  • refund_processed

Return Value

Return the modified notification configuration array.

return $defaults;

You can add new notification configurations or modify existing ones.

Basic Usage

add_filter( 'suredonation_default_email_notifications', 'your_custom_function', 10,1 );

function your_custom_function( $defaults ) {

// Add or modify notifications here.

return $defaults;

}

Example: Add a Custom Thank-You Email

The following example adds a custom notification that is sent when a donation is completed.

add_filter( 'suredonation_default_email_notifications', 'mysite_add_notification', 10, 1);

function mysite_add_notification( $defaults ) {

$defaults[] = [

'id'         => 20,

'status'     => true,

'name'       => 'Custom Thank-You',

'email_to'   => '{donor_email}',

'subject'    => 'Thank you, {donor_name}!',

'email_body' => '<p>We received your donation of {amount}.</p>',

'trigger'    => 'donation_completed',

];

return $defaults;

}

The new notification will use the donor’s email address and include the donor’s name and donation amount through smart tags.

Using Smart Tags

Notification templates can use SureDonation smart tags.

For example:

{donor_name}
{donor_email}
{amount}
{campaign_name}
{transaction_id}
{payment_status}

You can add or modify available smart tags using: suredonation_email_smart_tags

If you introduce custom smart tags, consider also adding them to the email editor’s tag picker using: suredonation_email_smart_tag_groups

Example: Add a Custom Administrator Notification

You can also create an email notification for an administrator.

add_filter( 'suredonation_default_email_notifications', 'mysite_add_admin_notification', 10, 1);

function mysite_add_admin_notification( $defaults ) {

$defaults[] = [

'id'         => 21,

'status'     => true,

'name'       => 'New Donation Alert',

'email_to'   => '[email protected]',

'subject'    => 'New donation received',

'email_body' => '<p>{donor_name} donated {amount}.</p>',

'trigger'    => 'donation_completed',

];

return $defaults;

}

Notification Flow

The filter is applied when SureDonation builds its default email notification configuration.

Default notification templates

          â†“

suredonation_default_email_notifications

          â†“

Custom notifications added or modified

          â†“

Notification configuration loaded

          â†“

Donation event occurs

          â†“

Matching notification is triggered

          â†“

Smart tags are replaced

          â†“

Email is sent

This filter is applied in:

Assets::get_default_email_notifications()

When adding a notification:

  • Use a unique id.
  • Provide a clear notification name.
  • Set an appropriate trigger.
  • Use valid email addresses or supported smart tags.
  • Return the complete $defaults array.
  • Use translated strings where appropriate for user-facing text.

If you only need to add or modify smart-tag values, use suredonation_email_smart_tags instead of modifying the notification configuration.

Related Hooks

  • Suredonation_email_smart_tags: Filters the smart-tag replacement values used when rendering notification emails.
  • Suredonation_email_sent: Fires after a SureDonation email has been sent.
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