请参见下面的代码:
function action_wpcf7_after_flamingo( $result ) {
if($result['contact_form_id'] == 329){
/** SOME CALCULATIONS HERE **/
$url = ; //Url to payment Checkout
wp_redirect($url);
exit;
}
}
add_action( 'wpcf7_after_flamingo', 'action_wpcf7_after_flamingo', 10, 1 );
在上述功能中,我想根据联系表单的值进行一些计算,然后将浏览器重定向到付款网关结帐页面。
我能够根据联系表单的值进行一些计算,但是wp_redirect()无法正常工作。请分享如何在任何add_action();中重定向到另一个URL。
wp_redirect()在页面输出开始后不起作用。您可以使用javascript进行重定向:
window.location.href = "http://www.w3schools.com";