duanchuiwen6694 2018-06-28 05:42
浏览 102

wordpress联系form7,一个表单重定向到基于is_page的多个感谢页面

I am looking for a solution on wordpress contact form7. either a plugin or in PHP code. I am not looking for JavaScript solution. as I have already found JavaScript solution. Again: I am looking for either plugin or PHP code. I want to use one form (CF7) and it will redirect to multiple thank you pages based on from which page the form submitted. Below example code.

if is_page(1){
  contact-form will go to thank-you-page-1
} else if is_page(2) {
  contact-form will go to thank-you-page-2
}
  • 写回答

1条回答 默认 最新

  • douzhizao0270 2018-06-28 05:57
    关注

    You can do by this hook

    add_action('wpcf7_mail_sent', function ($cf7) {
    
        // Run code after the email has been sent
    $wpcf = WPCF7_ContactForm::get_current();
     $wpccfid=$wpcf->id;
    
        // if you wanna check the ID of the Form $wpcf->id
         if ( '34' == $wpccfid ) { // Change 123 to the ID of the form 
    
             //you can use also if(is_page()){} condition 
    
        //redirect to url
        wp_redirect('url of thank you page');
         exit();
    
         }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算