Every form has a set of customizable messages displayed to users after submission. These messages are configured in the Messages tab when editing a form.
Default Messages
When you create a new form, these default messages are set:
- Success (
success): “Thank you! We will be in touch soon.” - Invalid email (
invalid_email): “Sorry, that email address looks invalid.” - Required field missing (
required_field_missing): “Please fill in the required fields.” - General error (
error): “Oops. An error occurred.” - reCAPTCHA failed (
recaptcha_failed): “reCAPTCHA verification failed. Please try again.” - reCAPTCHA low score (
recaptcha_low_score): “Your submission appears to be spam. Please try again.” - Spam detected (
spam): “Your submission was flagged as spam.” - Math CAPTCHA failed (
math_captcha_failed): “Incorrect answer to the math problem. Please try again.”
Extensions add their own messages:
- File too large (
file_too_large): “Uploaded file is too large.” - File upload error (
file_upload_error): “An upload error occurred. Please try again later.” - Submission limit reached (
submission_limit_reached): “The submission limit for this form has been reached.” - Login required (
require_user_logged_in): “You must be logged in before you can use this form.”
Customizing Messages
To change a message for a specific form, go to the Messages tab in the form editor and update the text for any message.
Custom messages are stored as post meta with the prefix cf_message_. For example, the success message is stored in cf_message_success.
How Messages Are Displayed
After form submission, the response includes a message type (success or error) and the message text. The JavaScript handler displays this message in the .cf-messages container within the form.
The messages container uses role="status" and aria-live="polite" attributes so screen readers announce the message when it appears.
Spam Handling
When a submission is flagged as spam (by Akismet, reCAPTCHA, or other spam detection), the form returns a success response to the user. This is intentional. Bots that see an error response will keep trying with different inputs. By returning success, spam bots move on thinking their submission went through.
The submission is still saved to the database (if save_submissions is enabled) but is marked with is_spam = 1.
Filtering Messages
Individual messages can be filtered using cf_form_message_{code}:
add_filter( 'cf_form_message_success', function( $message, $form ) {
return 'Thanks! We got your message.';
}, 10, 2 );
All default messages can be modified at once using cf_form_default_messages:
add_filter( 'cf_form_default_messages', function( $messages ) {
$messages['success'] = 'Message received.';
$messages['error'] = 'Something went wrong.';
return $messages;
} );
Data Attributes
Form messages are also passed as data attributes on the <form> element (e.g., data-message-success, data-message-error). The JavaScript uses these to display the appropriate message based on the server response.