Support » Plugin: Contact Form 7 » Integrating Contact Form 7 with a web service and editng validation_error messag

  • I am trying to reconfigure a Contact Form 7 form and I’m having 2 majors barriers. Let me explain the scenario. I am creating a registration form that when submitted will call a web service. That web service will handle the data validation and error messages, including checking to see if the user already exits based on email. The 2 major barriers are:

    1. I need to invalidate the form when I call the hook wpcf7_before_send_mail but I don’t see any examples of how to, or if it is even possible. Since the web service does all the validation I can’t use the typical validation hooks like wpcf7_validate_text* because not all the form fields are text fields and I need to be able to send all the data at once to the web service to either register the user or return an invalid error message.
    2. How can I change the validation_error message that appears at the bottom of the form (or where ever you put the [response] shortcode), rather than the field by field error called “reason?” I need one global error message that I can replace with the response from the web service rather than field by field errors.

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

Viewing 1 replies (of 1 total)
  • I have made a basic attempt to reset the status/valid state of the form and the validation_error message on wpcf7_before_send_mail with no success. Any suggestions?

    function wpcf7_do_something (&$WPCF7_ContactForm) {
        $WPCF7_ContactForm['status']='validation_failed';
        $WPCF7_ContactForm['valid']=false;
        $WPCF7_ContactForm['response'] = 'User Exits';
        return $WPCF7_ContactForm;
    }
    add_action("wpcf7_before_send_mail", "wpcf7_do_something");
Viewing 1 replies (of 1 total)
  • The topic ‘Integrating Contact Form 7 with a web service and editng validation_error messag’ is closed to new replies.