Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. Problema integrazione checkbox privacy in contact form CMS

Problema integrazione checkbox privacy in contact form CMS

Pianificato Fissato Bloccato Spostato Coding
1 Post 1 Autori 670 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • A
    A
    adenina
    scritto su ultima modifica di
    User Newbie 0
    #1
    Problema integrazione checkbox privacy in contact form CMS

    Perdonate il titolo a formato telegrafico.
    Ho integrato nel template dei contatti di un tema wordpress il checkbox della privacy ( di default non presente).
    Il problema è che ottengo l'errore di validazione (Il consenso è obbligatorio) che io spunti o no il checkbox della Privacy.
    Premetto che sono inesperta di PHP.

    Posto il codice della pagina ( le parti che ho inserito io sono commentate)

    Grazie in anticipo!

    <?php
        /*Template Name: Contact form*/
    ?>
    <?php global $SMTheme;?>
    <?php  
    
        if (isset($_POST[$_SESSION['commentinput']])&&$form=$_POST[$_SESSION['commentinput']]) {
            $msg='';
            $error='';
            $errorcode='red';
            $privacy=$_POST['privacy']; // parte che ho inserito
            foreach ($SMTheme->get( 'contactform', 'contactform' ) as $key=>$detail) {
                if ($detail['req']=='required'&&$form[$key]=='') $error.='Field '.$detail['ttl']." is required<br />";
                if ($detail['regex']!=''&&!eregi(stripslashes($detail['regex']),$form[$key])) {
                    $error.='Field '.$detail['ttl']." is not valid<br />";
                }
                $msg.=$detail['ttl'].": ".$form[$key]."\r\n";
            }
            
    //parte che ho inserito
                if ($privacy !=1) {
            $error.='Il consenso è obbligatorio<br />';
            } 
    //fine 
            $from=($SMTheme->get( 'general','sitename' ))?$SMTheme->get( 'general','sitename' ):get_bloginfo('name');
            if ($error=='') {
                wp_mail($SMTheme->get( 'contactform', 'email' ), 'Message from '.$from, $msg);
                $error=$SMTheme->_( 'emailok' );
                $errorcode='green';
            }
        }        
    ?>
    <?php
        get_header();
    ?>
    <div class='articles'>
        <?php
        the_post(); 
        ?>
            <div class='one-post'>
            <div id="post-<?php the_ID(); ?>" <?php post_class("post-caption"); ?>>
                <?php if (!is_single()&&!is_page()) { ?>
                <h2><a href="<?php the_permalink(); ?>" title="<?php printf( $SMTheme->_( 'permalink' ), the_title_attribute( 'echo=0' ) ); ?>" class='post_ttl'><?php the_title(); ?></a></h2>
                <?php } else { ?>
                    <h1><?php the_title(); ?></h1>
                <?php } ?>
            </div>
            <div class='post-body'>
                <?php
                    the_content('');
                ?>
            
            <?php if ( $SMTheme->get( 'contactform','address' ) != '' ) {?>
            <div class='googlemap waiting'><div id="map_canvas" style="width: 100%; height: 300px;"></div></div>
            
            <script>jQuery(function(){loadGMap('<?php echo $SMTheme->get( 'contactform','address' )?>', 'map_canvas', 16)});</script>
    
            <?php } ?>
    
    <?php
        if ($SMTheme->get( 'contactform', 'email' )) {
    ?>
    <form action='' method='POST' class='feedback'>
    <h3><?php echo $SMTheme->_( 'feedbackttl' ); ?></h3>
    <i><?php echo $SMTheme->_( 'feedbackbefore' ); ?></i>
        <?php
            foreach ($SMTheme->get( 'contactform', 'contactform' ) as $key=>$detail) {
                switch ($detail['type']) {
                    case 'text':
                    ?>
    <p><?php echo $detail['ttl']?>: <?php echo ($detail['req']=='required')?'(*)':''?>
    <div class='input'><input type='text' value='' name='<?php echo $key?>'<?php echo ($detail['req']=='required')?" required='true'":''?> /></div>
    </p>
                    <?php
                    break;
                    case 'textarea':
                    ?>
    <p><?php echo $detail['ttl']?>: <?php echo ($detail['req']=='required')?'(*)':''?>
    <div class='input'><textarea rows='5' name='<?php echo $key?>'<?php echo ($detail['req']=='required')?" required='true'":''?>></textarea></div>
    </p>
                    <?php
                    break;
                }
            }
        ?>
    
    // parte che ho inserito
    <p>
    <input name="privacy" type="checkbox" id="privacy" value="1" />
    <label for="privacy">Dichiaro di aver letto e accettato <a href="Privacy.html">l'informativa sulla Privacy</a></label></p>
    // fine
    <?php echo ($error!='')?"<p style='color:".$errorcode."'>".$error."</p>":''?>
    <center><input type='submit' class='readmore'  name='submit' value='<?php echo $SMTheme->_( 'send' );?>' /></center>
    </form>
    <?php } ?>
    <?php if ($SMTheme->get( 'contactform','detailttl' ) != '') {?>
    <h3><?php echo $SMTheme->get( 'contactform','detailttl' )?></h3>
    <?php } ?>
    <?php if ($SMTheme->get( 'contactform','text' )) { ?>
    <div style='margin-bottom:20px;'>
    <?php echo $SMTheme->get( 'contactform','text' )?>
    </div>
    <?php } 
    
        $details=$SMTheme->get( 'contactform', 'details' );
        if (!empty($details)) {
    ?>
    <div id='contact'><ul class='contact-details'>
        <?php
            foreach ($details as $key=>$detail) {
            ?>
                <li class='contact<?php echo $key?>'><?php echo $detail['content']?></li>
            <?php
            }
        ?>
    </ul></div>
    <style>
                        <?php
                            foreach ($SMTheme->get( 'contactform', 'details' ) as $key=>$detail) {
                            ?>
                        ul.contact-details li.contact<?php echo $key?> {
                            background:url(<?php echo $detail['img']?>) left top no-repeat;
                        }
                            <?php
                            }
                        ?>
                    </style>
    <?php } else { ?>
        <style>
            form.feedback { width:100%;    }
        </style>
    <?php    
        }
    ?>
    </div>
            </div>
     </div>
     <script>
        jQuery('.feedback input').each(function(){
            jQuery(this).attr('name','<?php echo $_SESSION['commentinput']; ?>['+jQuery(this).attr('name')+']');
        });
        jQuery('.feedback textarea').each(function(){
            jQuery(this).attr('name','<?php echo $_SESSION['commentinput']; ?>['+jQuery(this).attr('name')+']');
        });
     </script>
    <?php
        get_footer();
    ?>
    
    1 Risposta Ultima Risposta
    Miglior risposta 0
    0

    Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

    Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

    Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

    Registrati Accedi
    Rispondi
    • Risposta alla discussione
    Effettua l'accesso per rispondere
    • Da Vecchi a Nuovi
    • Da Nuovi a Vecchi
    • Più Voti


    • Accedi

    • Non hai un account? Registrati

    • Accedi o registrati per effettuare la ricerca.
    • Primo post
      Ultimo post
    Home Accedi Registrati
    Menu
    • CATEGORIES
    • La Community Connect.gt
    • Presentati alla Community
    • News Ufficiali da Connect.gt
    • Internet News
    • A Scuola Di
    • Digital Marketing
    • Intelligenza Artificiale
    • SEO & GEO
    • Web Marketing e Content
    • Google Analytics e Web Analytics
    • Google Ads & Advertising
    • YouTube
    • TikTok, Instagram e altri Social
    • Google Adsense, Affiliazioni e Guadagno
    • E-Commerce
    • Coding e Sistemistica
    • Help Center: consigli per il tuo progetto
    • Hosting e Cloud
    • Coding
    • CMS & Piattaforme Self-Hosted
    • Annunci e Collaborazioni
    • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
    • Collaborazioni WEB e Lavoro: offro e cerco
    • Impresa, Fisco e Leggi
    • Consulenza Legale e Professioni Web
    • Consulenza Fiscale, Imprese, Startup e P.Iva
    • Gli Off Topic
    • PC, Smartphone e altri Hardware
    • Tutti i Software
    • GT Fetish Cafè
    • Discussioni
    • Non letti 0
    • Recenti
    • Hashtag
    • Popolare
    • Utenti
    • Privacy
    • Termini e condizioni
    • © 2026 Search On Media Group S.r.l.