Để hạn chế sử dụng plugin và đôi khi sử dụng chung với plugin khác sẽ gây ra xung đột nên mình thấy cách này khá ok và hiệu quả , và kết nối cũng khá đơn giản ! hãy xem kỹ và làm theo nhé
Video Hướng dẫn :
Code chèn vào file functions.ph
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /*gửi from về google shet */ add_action( 'wpcf7_mail_sent', 'send_contact_form_to_google_sheets' ); function send_contact_form_to_google_sheets( $contact_form ) { $title = $contact_form->title(); $submission = WPCF7_Submission::get_instance(); if ( $submission ) { $posted_data = $submission->get_posted_data(); // Get the ID of the contact form $contact_form_id = $contact_form->id(); // Check if the ID of the contact form is the one you want to send data if ( $contact_form_id == 1833 ) { $fields = array( 'entry.524787103'=>urlencode($submission->get_meta( 'remote_ip' )), 'entry.94905923'=>urlencode($posted_data['your-name']), 'entry.47250285'=>urlencode($posted_data['your-add']), 'entry.771361845'=>urlencode($posted_data['your-nationality']), 'entry.302061264'=>urlencode($posted_data['your-natio']), 'entry.948454092'=>urlencode($posted_data['data']), 'entry.1632517699'=>urlencode($posted_data['your-tel']), 'entry.1152377622'=>urlencode($posted_data['your-email']), 'entry.1048909996'=>urlencode($posted_data['your-company']), 'entry.369972501'=>urlencode($posted_data['company-type']), 'entry.632318551'=>urlencode($posted_data['company-size']), 'entry.1805943606'=>urlencode($posted_data['your-message']), ); $url = 'https://docs.google.com/forms/u/0/d/e/1FAIpQLSc6ZyLO5AMNlMr8tvHhWI9k9F8Fotx88qWUx8otOdfKDtIdRg/formResponse'; $fields_string = ''; foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); } } } |
Có Thể Bạn Quan Tâm:
- Cách cài SMTP bằng API bằng Gmail SMTP Server trên WordPress
- Những đoạn code làm website bán hàng với Woocommerce cần biết phần 2
- Làm website bán hàng với Woocommerce và những đoạn code tuỳ biết nên sài .
- Những đoạn Code cần khi nâng cấp WordPress lên phiên bản 6.2 mới
- 13 plugin cần thiết cho website wordpress tạo khoá học online