<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problema integrazione checkbox privacy in contact form CMS]]></title><description><![CDATA[<p dir="auto">Perdonate il titolo a formato telegrafico.<br />
Ho integrato nel template dei contatti di un tema wordpress il checkbox della privacy ( di default non presente).<br />
Il problema è che ottengo l'errore di validazione (<em>Il consenso è obbligatorio</em>) che io spunti o no il checkbox della Privacy.<br />
Premetto che sono inesperta di PHP.</p>
<p dir="auto">Posto il codice della pagina ( le parti che ho inserito io sono commentate)</p>
<p dir="auto">Grazie in anticipo!</p>
<pre><code class="language-php">&lt;?php
    /*Template Name: Contact form*/
?&gt;
&lt;?php global $SMTheme;?&gt;
&lt;?php  

    if (isset($_POST[$_SESSION['commentinput']])&amp;&amp;$form=$_POST[$_SESSION['commentinput']]) {
        $msg='';
        $error='';
        $errorcode='red';
        $privacy=$_POST['privacy']; // parte che ho inserito
        foreach ($SMTheme-&gt;get( 'contactform', 'contactform' ) as $key=&gt;$detail) {
            if ($detail['req']=='required'&amp;&amp;$form[$key]=='') $error.='Field '.$detail['ttl']." is required&lt;br /&gt;";
            if ($detail['regex']!=''&amp;&amp;!eregi(stripslashes($detail['regex']),$form[$key])) {
                $error.='Field '.$detail['ttl']." is not valid&lt;br /&gt;";
            }
            $msg.=$detail['ttl'].": ".$form[$key]."\r\n";
        }
        
//parte che ho inserito
            if ($privacy !=1) {
        $error.='Il consenso è obbligatorio&lt;br /&gt;';
        } 
//fine 
        $from=($SMTheme-&gt;get( 'general','sitename' ))?$SMTheme-&gt;get( 'general','sitename' ):get_bloginfo('name');
        if ($error=='') {
            wp_mail($SMTheme-&gt;get( 'contactform', 'email' ), 'Message from '.$from, $msg);
            $error=$SMTheme-&gt;_( 'emailok' );
            $errorcode='green';
        }
    }        
?&gt;
&lt;?php
    get_header();
?&gt;
&lt;div class='articles'&gt;
    &lt;?php
    the_post(); 
    ?&gt;
        &lt;div class='one-post'&gt;
        &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class("post-caption"); ?&gt;&gt;
            &lt;?php if (!is_single()&amp;&amp;!is_page()) { ?&gt;
            &lt;h2&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php printf( $SMTheme-&gt;_( 'permalink' ), the_title_attribute( 'echo=0' ) ); ?&gt;" class='post_ttl'&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
            &lt;?php } else { ?&gt;
                &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
            &lt;?php } ?&gt;
        &lt;/div&gt;
        &lt;div class='post-body'&gt;
            &lt;?php
                the_content('');
            ?&gt;
        
        &lt;?php if ( $SMTheme-&gt;get( 'contactform','address' ) != '' ) {?&gt;
        &lt;div class='googlemap waiting'&gt;&lt;div id="map_canvas" style="width: 100%; height: 300px;"&gt;&lt;/div&gt;&lt;/div&gt;
        
        &lt;script&gt;jQuery(function(){loadGMap('&lt;?php echo $SMTheme-&gt;get( 'contactform','address' )?&gt;', 'map_canvas', 16)});&lt;/script&gt;

        &lt;?php } ?&gt;

&lt;?php
    if ($SMTheme-&gt;get( 'contactform', 'email' )) {
?&gt;
&lt;form action='' method='POST' class='feedback'&gt;
&lt;h3&gt;&lt;?php echo $SMTheme-&gt;_( 'feedbackttl' ); ?&gt;&lt;/h3&gt;
&lt;i&gt;&lt;?php echo $SMTheme-&gt;_( 'feedbackbefore' ); ?&gt;&lt;/i&gt;
    &lt;?php
        foreach ($SMTheme-&gt;get( 'contactform', 'contactform' ) as $key=&gt;$detail) {
            switch ($detail['type']) {
                case 'text':
                ?&gt;
&lt;p&gt;&lt;?php echo $detail['ttl']?&gt;: &lt;?php echo ($detail['req']=='required')?'(*)':''?&gt;
&lt;div class='input'&gt;&lt;input type='text' value='' name='&lt;?php echo $key?&gt;'&lt;?php echo ($detail['req']=='required')?" required='true'":''?&gt; /&gt;&lt;/div&gt;
&lt;/p&gt;
                &lt;?php
                break;
                case 'textarea':
                ?&gt;
&lt;p&gt;&lt;?php echo $detail['ttl']?&gt;: &lt;?php echo ($detail['req']=='required')?'(*)':''?&gt;
&lt;div class='input'&gt;&lt;textarea rows='5' name='&lt;?php echo $key?&gt;'&lt;?php echo ($detail['req']=='required')?" required='true'":''?&gt;&gt;&lt;/textarea&gt;&lt;/div&gt;
&lt;/p&gt;
                &lt;?php
                break;
            }
        }
    ?&gt;

// parte che ho inserito
&lt;p&gt;
&lt;input name="privacy" type="checkbox" id="privacy" value="1" /&gt;
&lt;label for="privacy"&gt;Dichiaro di aver letto e accettato &lt;a href="Privacy.html"&gt;l'informativa sulla Privacy&lt;/a&gt;&lt;/label&gt;&lt;/p&gt;
// fine
&lt;?php echo ($error!='')?"&lt;p style='color:".$errorcode."'&gt;".$error."&lt;/p&gt;":''?&gt;
&lt;center&gt;&lt;input type='submit' class='readmore'  name='submit' value='&lt;?php echo $SMTheme-&gt;_( 'send' );?&gt;' /&gt;&lt;/center&gt;
&lt;/form&gt;
&lt;?php } ?&gt;
&lt;?php if ($SMTheme-&gt;get( 'contactform','detailttl' ) != '') {?&gt;
&lt;h3&gt;&lt;?php echo $SMTheme-&gt;get( 'contactform','detailttl' )?&gt;&lt;/h3&gt;
&lt;?php } ?&gt;
&lt;?php if ($SMTheme-&gt;get( 'contactform','text' )) { ?&gt;
&lt;div style='margin-bottom:20px;'&gt;
&lt;?php echo $SMTheme-&gt;get( 'contactform','text' )?&gt;
&lt;/div&gt;
&lt;?php } 

    $details=$SMTheme-&gt;get( 'contactform', 'details' );
    if (!empty($details)) {
?&gt;
&lt;div id='contact'&gt;&lt;ul class='contact-details'&gt;
    &lt;?php
        foreach ($details as $key=&gt;$detail) {
        ?&gt;
            &lt;li class='contact&lt;?php echo $key?&gt;'&gt;&lt;?php echo $detail['content']?&gt;&lt;/li&gt;
        &lt;?php
        }
    ?&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;style&gt;
                    &lt;?php
                        foreach ($SMTheme-&gt;get( 'contactform', 'details' ) as $key=&gt;$detail) {
                        ?&gt;
                    ul.contact-details li.contact&lt;?php echo $key?&gt; {
                        background:url(&lt;?php echo $detail['img']?&gt;) left top no-repeat;
                    }
                        &lt;?php
                        }
                    ?&gt;
                &lt;/style&gt;
&lt;?php } else { ?&gt;
    &lt;style&gt;
        form.feedback { width:100%;    }
    &lt;/style&gt;
&lt;?php    
    }
?&gt;
&lt;/div&gt;
        &lt;/div&gt;
 &lt;/div&gt;
 &lt;script&gt;
    jQuery('.feedback input').each(function(){
        jQuery(this).attr('name','&lt;?php echo $_SESSION['commentinput']; ?&gt;['+jQuery(this).attr('name')+']');
    });
    jQuery('.feedback textarea').each(function(){
        jQuery(this).attr('name','&lt;?php echo $_SESSION['commentinput']; ?&gt;['+jQuery(this).attr('name')+']');
    });
 &lt;/script&gt;
&lt;?php
    get_footer();
?&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/topic/204077/problema-integrazione-checkbox-privacy-in-contact-form-cms</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 23:43:21 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/204077.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 13 Jul 2014 10:16:12 GMT</pubDate><ttl>60</ttl></channel></rss>