• I am trying (while learning WP) to create a form which will be submitted not through an email, but to a RestFul webservice outside of WP world.

    Currently, I have succeeded (outside of WP world) to POST an HTML form to the web service from a regular HTML page (it collect an email ID, and submit it together with two hidden values to the web service):

    <form action="url-of-Restful-webservice" method=POST target="_self">
       Email ID: <input type="email" name="email_id" value="Your Email Id">
      <input type="hidden" name="account_id" value="some_value">
      <input type="hidden" name="coupon_id" value="some_value">
      <input type="submit" value="Email Coupon" style="background-color:#688A08;font-weight:bold;">
    </form>

    How do I achieve the same from WP forms, e.g. Contact-Form-7?

    Thanks for your help and time

    Regards

    John Zhu

Viewing 2 replies - 1 through 2 (of 2 total)
  • I can’t see anywhere in the settings for ContactForm7 where you can control the value of the form’s action parameter. You could edit Contact Form 7’s plugin code, or change the action value using Javascript post page load, but both methods seem unsatisfactory.

    Consider making a custom shortcode, say: [my_form]

    functions.php of your child theme needs to give effect to this:

    <?php
      add_shortcode('my_form', 'my_form');
      function my_form() {
        $html = '<form action="url-of-Restful-webservice" .........
        $html .= (rest of form code)
        return $html;
      }

    Thread Starter zhuzh1

    (@zhuzh1)

    Lorro,

    Thanks for response. I’ll follow up with your suggestion.

    Regards

    John

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to make a WebService call to an external server’ is closed to new replies.