簡體   English   中英

如何在聯系表格7中提交表格后重定向?

[英]How to redirect after form submission in contact form 7?

我正在使用聯系表格 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?

任何人都可以幫助完成這項工作。

您還可以使用可用的鈎子來更改屬性

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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM