gpt4 book ai didi

php - 如何在联系表 7 中提交表单后重定向?

转载 作者:搜寻专家 更新时间:2023-10-31 21:29:50 24 4
gpt4 key购买 nike

我正在使用联系表格 7 提交表格并使用 wpcf7_before_send_mail 通过 soap 客户端生成引用号。

代码是

function wpcf7_do_something($WPCF7_ContactForm)
{

if (3490 == $WPCF7_ContactForm->id()) {
$client = new SoapClient('http://xxx.xxx.xxx.xxx:xxxxx/4dwsdl', array('trace' => 1));
$res_date = date("Y-m-d", strtotime('01 feb 2015'));
$enquiry_id = $client->__call('WS_AddContact',
array(
'narwal Devender',
null,
'Devender',
'narwal',
'hisar',
'Hisar',
'Haryana',
'125001',
'Australia',
'01662246138',
'9802260750',
'8529000369',
'vijaylal@webmastershisar.com',
true,
'google',
'google',
'Phone Call',
0,
'type of good should be strode.',
$res_date,
'2 to 6 Months',
'SSPSS',
null,//array('xxxxxxx'),
array('46.75'),
array('1 x 1 x 1 (1qm)'),
array('xxxxxxxxx'),
array('send print should be here to work.'),
null,
'xxxxxxxxxxxxx',
null
)
);


mail('vijaylal@webmastershisar.com', 'My Subject', $enquiry_id);

}
return $wpcf7;
}

这工作正常并发送电子邮件。

但我想在谢谢页面或任何页面上向自定义显示查询 ID,或者通过使用一些重定向并将数据发送到 url。

我也在尝试在 wpcf7_mail_sent 中使用此代码,这也有效,

但是当我尝试使用重定向时,它什么也不做,联系表只是挂起。

add_action('wpcf7_mail_sent', 'wpcf7_redirect_on_submit');

function wpcf7_redirect_on_submit($wpcf7)
{
header( 'Location: http://www.google.com' );
exit;
}

如何在不使用 javascript 或 jQuery on_sent_ok 的情况下重定向 wpcf7_mail_sent 中的联系表单?

如何在页面上向用户显示此查询 ID?

任何人都可以帮助完成这项工作。

最佳答案

您还可以使用可用的钩子(Hook)来更改属性

add_filter( 'wpcf7_contact_form_properties', 'let_me_redirect', 10, 2 );
/**
* Add the code that will run when on_sent_ok is triggered;
*/
function let_me_redirect( $properties, $contact_form_obj){
$properties[ 'additional_settings' ] .="on_sent_ok: \"location.replace('http://www.google.com');\""
;
return $properties;
}

关于php - 如何在联系表 7 中提交表单后重定向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31158839/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com