【问题标题】:Contact Form 7 set variable before send hook联系表格 7 在发送钩子之前设置变量
【发布时间】:2020-04-01 03:27:14
【问题描述】:

我想在提交电子邮件时设置报价单号。 这是我要设置的形式的变量。

[隐藏的frnum id:frnum]

在functions.php中

function wpcf7_setup_quotenum($WPCF7_ContactForm) {
if ($WPCF7_ContactForm->id() == '3550') {
     //Get current form
    $wpcf7      = WPCF7_ContactForm::get_current();

    // get current SUBMISSION instance
    $submission = WPCF7_Submission::get_instance();
    // Ok go forward
    if ($submission) {
        $_POST['frnum'] = 'test';
    }

}
}

这是获取号码的电子邮件代码。

[your-name] 认为您会对此叉车租赁报价感兴趣#:FR[frnum]

我最终将有代码将号码设置为唯一号码,我只是想在电子邮件中显示一些内容。

提前感谢您为我指明正确的方向。

【问题讨论】:

    标签: wordpress contact-form-7


    【解决方案1】:

    对于未来的任何人,这就是我最终的结果:

    if ($WPCF7_ContactForm->id() == '3550') {
         //Get current form
        $wpcf7      = WPCF7_ContactForm::get_current();
    
        // get current SUBMISSION instance
        $submission = WPCF7_Submission::get_instance();
        // Ok go forward
        if ($submission) {
            // do some replacements in the cf7 email body
            $mail         = $wpcf7->prop('mail');
            // Find/replace the "[frnum]" tag as defined in your CF7 email body
            // and add changes name
            $mail['body'] = str_replace('[frnum]', 'test', $mail['body']);
            //$mail['body'] = '[frnum]' => 'test';
    
            // Save the email body
            $wpcf7->set_properties(array(
                "mail" => $mail
            ));
    
            // return current cf7 instance
            return $wpcf7;
    
        }
    
    }
    

    【讨论】:

      猜你喜欢
      • 2017-02-13
      • 2019-05-28
      • 2015-12-23
      • 2017-04-24
      • 2018-04-16
      • 2018-09-25
      • 1970-01-01
      • 2010-10-01
      • 2018-06-01
      相关资源
      最近更新 更多