Integrating Elementor Form Fields with WordPress cURL for External API Data Submission

Question

I’m working on a WordPress project where I’ve implemented a custom function using cURL within functions.php to send data to an external API upon form submission. However, I’m facing challenges in dynamically capturing and mapping Elementor form field values to my cURL request.

    function welkvoxapi_shortcode() {
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'[{
            "customer_name": "namewv",
            "customer_last_name": "field_3d8268c",
            "id_type": " ",
            "customer_id": "field_d3976af ",
            "age": " ",
            "gender": " ",
            "country": " ",
            "state": "",
            "city": "field_5dd4679",
            "zone": "",
            "address": "",
            "opt1": "field_9f10881",
            "opt2": "",
            "opt3": "field_6d254ff",
            "opt4": "field_363c904",
            "opt5": "field_a5de87f",
            "opt6": "field_dc05404",
            "opt7": "field_9a9a683",
            "opt8": "field_383d50f",
            "opt9": "",
            "opt10": "",
            "opt11": "",
            "opt12": "",
            "tel1": "emailwv",
            "tel2": "",
            "tel3": "",
            "tel4": "",
            "tel5": "",
            "tel6": "",
            "tel7": "",
            "tel8": "",
            "tel9": "",
            "tel10": "",
            "tel_extra": "",
            "email": "field_8981d35",
            "recall_date": " ",
            "recall_telephone": " "

}]',
  CURLOPT_HTTPHEADER => array(
    'wolkvox-token: '
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


}
add_shortcode('wvoxapi', 'welkvoxapi_shortcode');

The platform’s name is Wolkvox. Here is the documentation for the integration.

Any insights on why the data might not be transmitting accurately to the platform despite adding the Elementor form fields with their IDs and ensuring the Token and cURL URL contain the correct information?

0
Diane Rendel 2 weeks 2023-11-20T10:39:26-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse