0

Contact Form 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");
?>
4

1 に答える 1