Quantcast
Channel: contact form 7 – WordPress.org Forums
Viewing all articles
Browse latest Browse all 9540

kamili on "[Plugin: Contact Form 7] wpcf7_before_send_mail - Trigger or Add Error Message"

$
0
0

I've used the wpcf7_before_send_mail hook and my custom function (wpcf7_register_gfuser_and_post) to help customize and process input from one of my contact form 7 forms. I can access the CF7 object and am able to successfully customize the input this way. The only roadblock I'm encountering is: I would like to correctly access the error message object array so I can trigger an error based on one of my conditions so the user will be able to make the correction before submitting the form again. I can access the object arrays: posted_data, skip_mail, form, ...just fine, but am having trouble accessing and setting the error messages object array.

For example:

$submitted_username = $WPCF7_ContactForm->posted_data['user-name'];
if( username_exists($submitted_username) ) { $add_to_error = "This username, $submitted_username, is already in use. "; }
if( !empty($add_to_error) ) {
 $WPCF7_ContactForm->skip_mail = true;
 //Not sure if I'm accessing error/validation message object correctly
 $WPCF7_ContactForm->messages['Not sure what might go here'] = $add_to_error;
} else { /* All the rest of the processing if no error */ }

Any hints would be greatly appreciated. Thank you.

http://wordpress.org/extend/plugins/contact-form-7/


Viewing all articles
Browse latest Browse all 9540

Trending Articles