簡體   English   中英

聯系表格 7 在發送鈎子之前設置變量

[英]Contact Form 7 set variable before send hook

我想在提交電子郵件時設置報價編號。 這是我要設置的表單中的變量。

[隱藏的 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';
    }

}
}

這是獲取號碼的電子郵件代碼。

[你的名字] 認為你會對這輛叉車租賃感興趣 報價#:FR[frnum]

我最終將擁有將數字設置為唯一數字的代碼,我只是想在電子郵件中顯示一些內容。

預先感謝您為我指明正確的方向。

對於未來的任何人,這就是我最終的結果:

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;

    }

}

暫無
暫無

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

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