• is there a way to make it work with this?

    function leads_integration_wp_cf7( $cf7 ) {
           $url = your_url_goes_here;
           $postparams = your_post_params_goes_here;
    
           $ch = curl_init($url);
           curl_setopt($ch, CURLOPT_POSTFIELDS, $postparams);
           curl_setopt($ch, CURLOPT_POST, 1);
           curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 );
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
           $output = curl_exec($ch);
           curl_close($ch);
    }
    add_action('wpcf7_mail_sent', 'leads_integration_wp_cf7');

    https://ww.wp.xz.cn/plugins/contact-form-7-multi-step-module/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kyledoesit

    (@kyledoesit)

    maybe something like this?

    $.ajax({
            type: "POST",
            url: "http://www.yoururl.com/",
            crossDomain: true,
            data: 'parm1=value1&param2=value2',
            success: function (data) {
                // do something with server response data
            },
            error: function (err) {
                // handle your error logic here
            }
        });
    Thread Starter kyledoesit

    (@kyledoesit)

    I’ve moved on to javascript now.
    First added this to my functions.php

    add_filter( 'wpcf7_form_id_attr', 'your_custom_form_id_attr' );
    
    function your_custom_form_id_attr( $id ) {
    	$id .= ' cf7-id';
    	return $id;
    }

    Right now my JS looks like this and am getting this error “Uncaught TypeError: Cannot read property ‘addEventListener’ of null”

    <script>
    document.getElementById("cf7-id").addEventListener("submit", myFunction);
    
    function myFunction() {
        alert("The form was submitted");
    }
    </script>

    Thread Starter kyledoesit

    (@kyledoesit)

    After moving that JS to the footer it has started working correctly, now I just need to set it to submit the form to a php file and it’ll be good to go!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Working with cURL’ is closed to new replies.