• I was wondering if there was a filter or a way to change contact form Messages? Usually when I install contact form 7, every time I create a form I change the default Messages and word them differently to what makes sense to me. Instead of changing these every time I create a form I’d rather use PHP and change all the forms Messages in 1 place.

    Is this possible? Does this make sense?

    https://wordpress.org/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Howdy_McGee

    (@howdy_mcgee)

    This is how I was able to change the messages, there may be a better way to go about it but to see all messages echo print_r($messages) or maybe if the creator catches this thread he could list all the $messages names:

    /** Contact Form 7 Default Messages **/
    function wpcf7_custom_messages($messages){
    	$messages['mail_sent_ok']['default'] 		= 'Your message has been sent!';
    	$messages['mail_sent_ng']['default'] 		= 'Your message could not be sent.';
    	$messages['validation_error']['default'] 	= 'Validation errors occurred. Check your information and submit again.';
    	$messages['spam']['default'] 				= 'Your message could not be sent.';
    	$messages['invalid_required']['default'] 	= 'This field is required.';
    	$messages['captcha_not_match']['default'] 	= 'Incorrect CAPTCHA - try again.';
    	$messages['invalid_email']['default'] 		= 'Invalid email address.';
    
    	return $messages;
    }
    add_filter( 'wpcf7_messages', 'wpcf7_custom_messages', 999 );

    It works. A big thank you for this!

    I’ve been messing around trying to do it with a translation file, which worked but is not really the right way to do it 😀 Luckily just searched again and caught this post.

    Folks, remember that if you’ve already made a form, the result messages won’t change there, because they have already been saved. Only when you start a new form. (It only took me a couple days to figure out why my messages weren’t changing — hopefully you are smarter than me!)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Changes WPCF7 Messages PHP’ is closed to new replies.