How to Change the Error Text for Failed Submissions

Would you like to change the error text that shows to your visitors on failed submissions? Various issues, from JavaScript errors to plugin conflicts or server-side problems, can cause your form not to submit. When this happens, a message will appear on the screen for your visitors.

Form submission error message

To troubleshoot why this could be happening, please take a look at our troubleshooting guide. However, you can easily change this message to something more user-friendly using a small PHP snippet.

Changing the error text

To change the error text, you’ll need to add a small snippet to your site. For assistance in adding snippets, please review this tutorial on adding custom PHP or JavaScript for WPForms.

/**
 * Change the error text message that appears.
 *
 * @link https://wpforms.com/developers/how-to-change-the-error-text-for-failed-submissions/
 */

function wpf_translated( $translated_text, $text, $domain ) {

    // Bail early if it's not a WPForms string.
    if ( $domain !== 'wpforms-lite' ) {
        return $translated_text;
    }

    // Compare against the original string (in English).
    if ( $text === 'Form has not been submitted, please see the errors below.' ) {
        $translated_text = __( 'Hey! Please check under the hood!', 'wpforms' );
    }

    return $translated_text;
}
add_filter( 'gettext', 'wpf_translated', 10, 3 );

The above snippet will only process if the error message The form was unable to submit. Please contact the site administrator. is present on the page.

You can use this snippet to change any error messages, required field messages, or validation messages that appear when the form fails to submit.

And that’s all you need to change the error messages. For a more in-depth look into what might cause this error, please check out our guide on Resolving ‘The form was unable to submit’ Issue in WPForms.

Reference Filter

gettext