Title: [Plugin] Contact Form 7 &#8211; Change result message before submit on function error
Last modified: August 21, 2016

---

# [Plugin] Contact Form 7 – Change result message before submit on function error

 *  [anatoli](https://wordpress.org/support/users/anatoli/)
 * (@anatoli)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/plugin-contact-form-7-change-result-message-before-submit-on-function-error/)
 * Hi,
    i read a lot of tricks about with wpcf7_mail_sent or wpcf7_before_send_mail.
 * I’m using the wpcf7_before_send_mail function but i need to change the result[‘
   message’] if my php function inside return an error.
 * I did:
 *     ```
       add_action( 'wpcf7_before_send_mail', 'MyChange');
   
       function MyChange($contact_form) {
       	 $idForm = $contact_form->id;
       	 $posted_data = $contact_form->posted_data;
       	 if ( 1367 == $idForm) {
       		try {
        			myfunction ($posted_data);
       		} catch (Exception $e){
       			$contact_form->skip_mail = true;
         			(********)$contact_form->result['message'] = $e->getMessage();
       		}
       	}
       }
       ```
   
 * Obviously e (********) line doesn’t works but… how can i do that?
 * Thanks a lot and sorry for my english! 😉

The topic ‘[Plugin] Contact Form 7 – Change result message before submit on function
error’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [anatoli](https://wordpress.org/support/users/anatoli/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/plugin-contact-form-7-change-result-message-before-submit-on-function-error/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
