How to Change the Error Text for Failed Submissions

Overview

Would you like to change the error text that shows to your visitors on failed submissions? There could be anything from a JavaScript error to a plugin conflict or even a server-side error that could cause your form not to submit. If this happens, a message will appear on the screen to your visitors.

failed 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 be whatever you would like using a small PHP snippet.

Setup

In order to change the error text, you’ll need to add a small snippet to your site. For any assistance in adding snippets to your site, please review this tutorial.

/**
 * 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 WPForms string.
	if ( $domain !== 'wpforms-lite' ) {
		
		return $translated_text;
	
	}

    // Compare against the original string (in English).
	if ( $text === 'The form was unable to submit. Please contact the site administrator.' ) {
		
		$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 could use this snippet to change any error messages, required messages, or validation messages that appear when the form is unable to submit.

And that’s all you need to change the error messages. Would you like to stop the scrolling that happens on validation errors? Take a look at our article on How to Disable the Scrolling Effect on Field Validation Errors.

Filter Reference: gettext