contact form 7 I want to run php code after submitting ? is it possible ?
I have php curl code I want to run it but I don’t know how to do it.
my php code :
<?php
$data = array(
'chatId' => '9011111@c.us',
'mentions' => array(
'9011111@c.us'
),
'text' => 'Hi there!',
'session' => 'default'
);
$options = array(
'http' => array(
'method' => 'POST',
'header' => "Content-type: application/json\r\n",
'content' => json_encode($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents('http://1.1.1.1:3000/api/sendText', false, $context);
echo $result;
?>
Is it possible how to do it?
>Solution :
yes, it is possible. you’ll need to use a WordPress hook wpcf7_mail_sent to do it. You need to wrap your cURL code into a funtion and then use the hook as follow:
add_action('wpcf7_mail_sent', 'your_function');