// ============================================ // ENVOI CONTACT FORM 7 VERS ZAPIER WEBHOOK // LifeTime Projects - Formulaire missions // ============================================ add_action('wpcf7_mail_sent', 'ltp_send_to_zapier'); function ltp_send_to_zapier($contact_form) { // ⚠️ REMPLACEZ PAR VOTRE URL WEBHOOK ZAPIER $webhook_url = 'https://hooks.zapier.com/hooks/catch/25867187/uwu3stc/'; // Récupération des données du formulaire $submission = WPCF7_Submission::get_instance(); if ($submission) { $posted_data = $submission->get_posted_data(); // Extraction des données avec vos noms de champs exacts $data = array( 'firstname' => isset($posted_data['mc4wp-FNAME']) ? sanitize_text_field($posted_data['mc4wp-FNAME']) : '', 'lastname' => isset($posted_data['mc4wp-LNAME']) ? sanitize_text_field($posted_data['mc4wp-LNAME']) : '', 'email' => isset($posted_data['mc4wp-EMAIL']) ? sanitize_email($posted_data['mc4wp-EMAIL']) : '', 'phone' => isset($posted_data['telephone-number']) ? sanitize_text_field($posted_data['telephone-number']) : '', 'statut' => isset($posted_data['votre-situation']) ? sanitize_text_field($posted_data['votre-situation']) : '', 'mission' => isset($posted_data['Projet']) ? sanitize_text_field($posted_data['Projet']) : '', 'dates' => isset($posted_data['dates-de-depart']) ? sanitize_text_field($posted_data['dates-de-depart']) : '', 'message' => isset($posted_data['your-message']) ? sanitize_textarea_field($posted_data['your-message']) : '', 'source' => isset($posted_data['comment-vous-nous-avez-connu']) ? sanitize_text_field($posted_data['comment-vous-nous-avez-connu']) : '', // Métadonnées utiles 'form_id' => $contact_form->id(), 'form_title' => $contact_form->title(), 'timestamp' => current_time('mysql'), 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'] ); // Envoi des données vers Zapier $response = wp_remote_post($webhook_url, array( 'body' => json_encode($data), 'headers' => array('Content-Type' => 'application/json'), 'timeout' => 15, 'sslverify' => true )); // Logging en cas d'erreur (optionnel, pour debug) if (is_wp_error($response)) { error_log('LTP Zapier Webhook Error: ' . $response->get_error_message()); } } }