Skip to content

Customizing email alerts with filters

Gravity Forms Feed Error Alerts lets you customize every part of the alert email process using filters. Whether you’re changing the subject line, tweaking the message body, or modifying the recipient dynamically, there’s a filter for it.

Below is a list of all available filters and how to use them.

 

Error object structure

The $errors array passed to many of the filters is an array of associative arrays, each representing a stored feed error.

Each error has the following keys:

  • error – the error message (string)
  • form_id – the Gravity Form ID (int)
  • entry_id – the Entry ID associated with the submission (int)
  • feed_id – the Feed ID that failed (int)
  • addon_slug – the addon’s internal slug (string)

Controlling whether an email is sent

gffea_should_send_alert

Use this filter to prevent an alert email from being sent. It receives a boolean and the full $errors array.

<?php
add_filter( 'gffea_should_send_alert', function( $should_send, $errors ) {
    // Example: skip alert if any errors are from a specific addon
    foreach ( $errors as $error ) {
        if ( $error['addon_slug'] !== 'myaddon' ) {
            return true;
        }
    }
    return false;
}, 10, 2 );

Limit how many errors show in digest emails

gffea_email_digest_max_errors

Defaults to 10. You can change this to control how many errors appear when an alert contains multiple. To have no maximum, you can return 0.

<?php
add_filter( 'gffea_email_digest_max_errors', function($max) {
    return 20;
});

Customize who the alert is sent to

gffea_email_send_to

This overrides the recipient email address set in plugin settings.

<?php
add_filter( 'gffea_email_send_to', function( $to, $errors ) {
    return '[email protected]';
}, 10, 2 );

Customize the subject line

gffea_email_subject

Use this to change the subject of the email alert.

<?php
add_filter( 'gffea_email_subject', function( $subject, $errors ) {
    return '🚨 Feed Error Notification';
}, 10, 2 );

Customize the raw email template

gffea_email_template

This is the base HTML template before any placeholders are replaced.

<?php
add_filter( 'gffea_email_template', function( $template, $errors ) {
    // return your own email template
    // See our article on customizing the email template and error block HTML
    return my_custom_error_alert_email_template($errors);
}, 10, 2 );

Customize the email title

gffea_email_title

This is the main title in the email (e.g., “Your Gravity Forms Feed Errors Summary”).

<?php
add_filter( 'gffea_email_title', function( $title, $errors ) {
    return ( count($errors) > 1 ) ? 'Uh-oh! We found problems with some feeds.' : 'Uh-oh! We found a problem with a feed.';
}, 10, 2 );

Customize the message text

gffea_email_message

Used for the short message that appears below the title.

<?php
add_filter( 'gffea_email_message', function( $message, $errors ) {
    return ( count($errors) > 1 ) ? 'The following feed errors were detected on your website.' : 'The following feed error was detected on your website.';
}, 10, 2 );

Customize how each error block looks

gffea_email_error_block

This controls how each error is rendered (within the loop over $errors).

<?php
add_filter( 'gffea_email_error_block', function( $block_html, $error ) {
    // return your own email template
    // See our article on customizing the email template and error block HTML
    return my_custom_error_block_email_template($error);
}, 10, 2 );

Final assembled email body

gffea_email_body

This is the final compiled HTML for the whole email after all placeholders have been replaced.

<?php
add_filter( 'gffea_email_body', function( $html, $errors ) {
    return str_replace('Feed Error Alerts', 'Feed Watcher 🚨', $html);
}, 10, 2 );

Email headers

gffea_email_headers

Use this to add CCs, BCCs, or custom headers.

<?php
add_filter( 'gffea_email_headers', function( $headers, $errors ) {
    $headers[] = 'BCC: [email protected]';
    return $headers;
}, 10, 2 );

After email is sent

gffea_after_error_alert_send

An action that fires after the email is sent (or skipped). This can be used to log, notify, or trigger integrations.

<?php
add_action( 'gffea_after_error_alert_send', function( $sent, $errors ) {
    error_log( $sent ? 'Alert sent!' : 'Alert failed to send.' );
});

Need help?

Want help integrating your own template or variables or have any suggestions? Contact us or browse more developer documentation.