<?php function editor_custom_content_bottom() { global $asgarosforum; if (!is_user_logged_in() && $asgarosforum->options['allow_guest_postings']) { $captcha_instance = new ReallySimpleCaptcha(); $captcha_word = $captcha_instance->generate_random_word(); $captcha_prefix = mt_rand(); $captcha_file = $captcha_instance->generate_image($captcha_prefix, $captcha_word); $captcha_url = plugins_url().'/really-simple-captcha/tmp/'.$captcha_file; echo '<div class="editor-row editor-row-captcha">'; echo '<span class="row-title">'.__('Captcha:', 'asgaros-forum').'</span>'; echo '<img src="'.$captcha_url.'" /><br />'; echo '<input type="text" name="captcha_value">'; echo '<input type="hidden" name="captcha_prefix" value="'.$captcha_prefix.'">'; echo '</div>'; } } add_action('asgarosforum_editor_custom_content_bottom', 'editor_custom_content_bottom'); function insert_custom_validation($status) { global $asgarosforum; if (!is_user_logged_in() && $asgarosforum->options['allow_guest_postings']) { $captcha_instance = new ReallySimpleCaptcha(); $captcha_value = $_POST['captcha_value']; $captcha_prefix = $_POST['captcha_prefix']; $captcha_correct = $captcha_instance->check($captcha_prefix, $captcha_value); $captcha_instance->remove($captcha_prefix); if (!$captcha_correct) { $asgarosforum->info = __('You must enter the correct captcha.', 'asgaros-forum'); return false; } } return $status; } add_filter('asgarosforum_filter_insert_custom_validation', 'insert_custom_validation'); ?>