WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Use Contact Form 7 with cURL? (2 posts)

  1. puppyguitar
    Member
    Posted 3 years ago #

    Hello,

    I'm using the Contact Form 7 plugin on my site, and in addition to its normal behavior of sending an email when the form is submitted, I would also like to post the form data to a second, remote URL using cURL. Could anyone suggest the best way to implement this?

  2. noxion
    Member
    Posted 2 years ago #

    In your functions.php insert 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');

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic