2013-12-15 53 views
0

我使用一個聯繫表格7 wordpress,我希望作爲複選框形式訪問者重定向到另一個頁面,但我正在嘗試的代碼不工作,尤其是部分的'foreach',你看到的問題我有?條件重定向

我的代碼:

<?php 
function wpcf7_do_something (&$WPCF7_ContactForm) { 
    // Détection du titre du formulaire pour ne traiter que le bon au cas où il y en a plusieurs 
    $title=$WPCF7_ContactForm->title; 
    //compteur de minutes 
    $cpt=0; 

    if ($title=='pvh_guide'){ 
     $cpt=20; // test ok 
     //foreach($WPCF7_ContactForm->services as $chkbx){ 
      //if ($chkbx=='10') $cpt+=10; // si on a coché la case 1, 2 ou 3 on ajoute 10 minutes au compteur 
      //if ($chkbx=='20') $cpt+=10; 
      //if ($chkbx=='30') $cpt+=10; 
     //} 
     // ensuite selon le comptage des minutes, on envoi sur une page avec une offre 
     if ($cpt==10) $WPCF7_ContactForm->additional_settings = "on_sent_ok: \"location.replace('http://locationcontainernamur.com/offre1');\""; 
     if ($cpt==20) $WPCF7_ContactForm->additional_settings = "on_sent_ok: \"location.replace('http://locationcontainernamur.com/offre2');\""; 
     if ($cpt==30) $WPCF7_ContactForm->additional_settings = "on_sent_ok: \"location.replace('http://locationcontainernamur.com/offre3');\""; 
     //$WPCF7_ContactForm->additional_settings = "on_sent_ok: \"location.replace('http://google.com/');\""; 
    } 
} 
add_action("wpcf7_before_send_mail", "wpcf7_do_something"); 
?> 
+0

沒有什麼似乎是錯了你的foreach,什麼是'$ chkbx'您的foreach後的價值?你確定重定向應該這樣做嗎?我懷疑你的JavaScript會中斷。需要更多信息。 – soulseekah

回答

0
on_sent_ok: "var Iso = $("input[name=radio-565]:checked").val() ; if(Iso == 'value1'){ location = 'www.bdparty24.com'; } if(Iso == 'value2'){ location = 'www.bdstore24.com'; }"