我正在尝试做一些事情,但它比预期的要困难一点,我需要帮助。
我想用我的表单做两件简单的事情: 1 - 在数据库中写入数据 2 - 在感谢页面上重定向
function createUser($contact_data)
{
var_dump($contact_data->posted_data);
$phone = $_POST['your-phone'];
$callname = $_POST['your-name'];
$pwd = $_POST['pwd'];
addUserInDB($phone,$pwd,$callname); /* this part works fine */
header('Location: https://www.google.com'); /* A - not working */
?>
<script type="text/javascript">
window.location.href = "https://google.com/"; /* B - not working */
document.addEventListener( 'wpcf7submit', function( event ) {
window.location.href = "https://google.com/"; /* C - not working */
}, false );
document.addEventListener( 'wpcf7mailsent', function( event ) {
window.location.href = "https://google.com/"; /* D - not working */
}, false );
</script>
<?php
}
add_action("wpcf7_mail_sent", "createUser", 10, 1);
我尝试了四种不同的方法,现在我不知道该怎么办了......