联系表格 7 我想在提交后运行 php 代码?是否可以 ? 我有 php curl 代码,我想运行它,但我不知道该怎么做。
我的PHP代码:
<?php
$data = array(
'chatId' => '[email protected]',
'mentions' => array(
'[email protected]'
),
'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;
?>
请问可以怎样做吗?
是的,这是可能的。您需要使用 WordPress 挂钩
wpcf7_mail_sent
来完成此操作。您需要将 cURL 代码包装到一个函数中,然后使用钩子,如下所示:
add_action('wpcf7_mail_sent', 'your_function');