Skip to content

Instantly share code, notes, and snippets.

@yeriepiscesa
Last active July 23, 2020 07:52
Show Gist options
  • Save yeriepiscesa/373ac024b04ac9cbcb55ac732f3ec704 to your computer and use it in GitHub Desktop.
Save yeriepiscesa/373ac024b04ac9cbcb55ac732f3ec704 to your computer and use it in GitHub Desktop.
Contact Form 7 Send to WhatsApp, integrasi pihak ketiga. https://solusipress.com/download/contact-form-7-send-to-whatsapp/
<?php
function solusipress_custom_wa_api_send( $data, $form_id ) {
/**
* Do something here
* $data contains this information:
[
'to_number' => 'the number you defined',
'message' => 'message content from mail tab template',
'cf7_inputs' => the_posted_data_array_from_cf7,
'to_number_2' => 'the number for autorespond',
'message_2' => 'message for autorespond'
]
*/
// example
$url = 'https://fonnte.com/api/send_message.php';
$inputs = [
'phone' => $data['to_number'],
'type' => 'text',
'text' => $data['message']
];
$curl = wp_remote_post( $url, array(
'body' => $inputs,
'headers' => array(
'Authorization' => 'your-auth-token-here'
)
) );
/* print_r($curl); */
// for autorespond
if( isset( $data['to_number_2'] ) ) {
$inputs = [
'phone' => $data['to_number_2'],
'type' => 'text',
'text' => $data['message_2']
];
wp_remote_post( $url, array(
'body' => $inputs,
'headers' => array(
'Authorization' => 'your-auth-token-here'
)
) );
}
}
add_action( 'cf7sendwa_custom_send_api', 'solusipress_custom_wa_api_send', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment