Halloween Sale 15% off Ends in See the plans
PHP

Friendlier Contact Form 7 Response Messages

Replaces the standard Contact Form 7 success, error and spam messages on every form with your own wording in one place.

Don’t have WPIDE yet? Install it on your site

Code

// CF7 message name => your text.
$wpide_cf7_messages = array(
    'mail_sent_ok'     => 'Thanks! Your message is on its way and we usually reply within one working day.',
    'mail_sent_ng'     => 'Sorry, something went wrong sending your message. Please try again or email us directly.',
    'validation_error' => 'Please check the highlighted fields and try again.',
    'spam'             => 'Your message could not be sent. If you are a real person, please email us directly.',
    'invalid_required' => 'This field is required.',
);

add_filter( 'wpcf7_display_message', function ( $message, $status = '' ) use ( $wpide_cf7_messages ) {
    return isset( $wpide_cf7_messages[ $status ] ) ? $wpide_cf7_messages[ $status ] : $message;
}, 10, 2 );

Notes

Keys are CF7 message names (mail_sent_ok, mail_sent_ng, validation_error, spam, accept_terms, invalid_required); remove a line to keep the form's own text.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.