Öncelikle temamızın comments.php dosyasında doğrulama kısmının görüntülenmesini istediğimiz yere aşağıdaki kodları ekliyoruz.
PHP- Kodu:
<?php
$sayi1 = rand(10, 20);
$sayi2 = rand(1, 9);
$sonuc = $sayi1 + $sayi2;
?>
<input type="hidden" name="sonuc" value="<? echo $sonuc;?>" />
<p class="input_block"><font face="tahoma" size="2"><b><?php echo $sayi1; ?> + <?php echo $sayi2; ?> = ?</b>
(İşleminin Sonucu)</font> <input type="text" name="gkodu" id="gkodu" value="" size="22" tabindex="3" /></p>
Bu kodlarımızı ekledikten sonra sitemizin ana dizininde bulunan wordpress dosyalarından olan wp-comments-post.php dosyasında ise aşağıda belirttiğim kısmı buluyoruz ve;
PHP- Kodu:
if ( get_option('require_name_email') && !$user->exists() ) {
if ( 6 > strlen($comment_author_email) || '' == $comment_author ) wp_die( __('<strong>ERROR</strong>: please fill the required fields (name, email).') );
elseif ( !is_email($comment_author_email)) wp_die( __('<strong>ERROR</strong>: please enter a valid email address.') );
}
aşağıda belirttiğim kodları altına ekliyoruz.
PHP- Kodu:
$gkodu = $_POST***91;"gkodu"***93;; $sonuc = $_POST***91;"sonuc"***93;;
if(!$gkodu){ wp_die( __('Lutfen Guvenlik Kodunu Yaziniz.<br><br><a href=javascript:history.go(-1)><b> << Geri </a>') );
}
if($gkodu != $sonuc){ wp_die( __('Guvenlik kodunu eksik yada yanlis girdiniz.<br><br><a href=javascript:history.go(-1)><b> << Geri </a>'.$sonuc.'ve'.$gkodu));
}
İşte bu kadar. Hayırlı olsun.