Merhaba arkdaşlar, herhangi bir eklenti olmadan yorumlara doğrulama koymak istiyorum....
2+5 gibi işlemler olabilir. Veya resim doğrulaması olabilir.
Bunu nasıl yapabilirim acaba?
Yorumlara doğrulama
7
●385
- 24-08-2010, 20:38:04functions.php ye ekle
add_action( 'comment_form', 'add_hidden_fields' ); function add_hidden_fields() { $mathvalue0 = rand(2, 15); $mathvalue1 = rand(2, 15); echo '<div><b>IMPORTANT!</b> To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-) <br/><br/>'; echo "What is $mathvalue0 + $mathvalue1 ?<br/>"; echo '<input type="text" name="mathvalue2" value="" />'; echo '</div>'; echo '<div style="display:none">Please leave these two fields as-is: '; echo "<input type='text' name='mathvalue0' value='$mathvalue0' />"; echo "<input type='text' name='mathvalue1' value='$mathvalue1' />"; echo '</div>'; } add_filter( 'preprocess_comment', 'preprocess_comment' ); function preprocess_comment( $commentdata ) { check_hidden_fields(); return $commentdata; } function check_hidden_fields() { // Get values from POST data $val0 = ''; $val1 = ''; $val2 = ''; if ( isset( $_POST['mathvalue0'] ) ) { $val0 = $_POST['mathvalue0']; } if ( isset( $_POST['mathvalue1'] ) ) { $val1 = $_POST['mathvalue1']; } if ( isset( $_POST['mathvalue2'] ) ) { $val2 = $_POST['mathvalue2']; } // Check values if ( ( $val0 == '' ) || ( $val1 == '' ) || ( intval($val2) != (intval($val0) + intval($val1)) ) ) { // Die and return error 403 Forbidden wp_die( 'Bye Bye, SPAMBOT!', '403 Forbidden', array( 'response' => 403 ) ); } } - 24-08-2010, 20:41:06niphell adlı üyeden alıntı: mesajı görüntüle
hacı verdiğin kodu ekledim, header sağa, sidebar sola, mesajlar kayboldu
