# Clearer Gravity Forms Error Summary

> Replaces the error message at the top of a Gravity Forms form with your own wording and lists how many fields need attention, announced to screen readers.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: gravity-forms, validation, accessibility
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/gf-validation-message/

## Code

```php
$wpide_gf_error_text = 'Almost there! Please fix the %d highlighted field(s) below.';

add_filter( 'gform_validation_message', function ( $message, $form ) use ( $wpide_gf_error_text ) {
    $count = 0;
    foreach ( $form['fields'] as $field ) {
        if ( ! empty( $field->failed_validation ) ) {
            $count++;
        }
    }

    return sprintf( '<div class="gform_validation_errors validation_error" role="alert"><h2 class="gform_submission_error">%s</h2></div>', esc_html( sprintf( $wpide_gf_error_text, max( 1, $count ) ) ) );
}, 10, 2 );
```

## Notes

Edit the sentence at the top; %d is replaced with the number of fields that need fixing.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Clearer Gravity Forms Error Summary" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
