Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Download and Install -> http://wordpress.org/extend/plugins/really-simple-captcha/
- Copy and Modify Template File at wp-content/plugins/events-manager/templates/placeholders/bookingform.php
- 1. copy php file at wp-content/plugins/events-manager/templates/placeholders/bookingform.php
- 2. paste in your current theme directory e.g. wp-content/themes/YOUR THEME NAME/plugins/events-manager/bookingform.php (create folders if not existing)
- 3. open and modify
- PASTE THIS SNIPPET
- ==================================
- <?php
- $captcha_instance = new ReallySimpleCaptcha();
- $captcha_instance->chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
- $captcha_instance->char_length = '4';
- // Width/Height dimensions of CAPTCHA image.
- $captcha_instance->img_size = array( '72', '24' );
- // Font color of CAPTCHA characters, in RGB (0 - 255).
- $captcha_instance->fg = array( '0', '0', '0' );
- // Background color of CAPTCHA image, in RGB (0 - 255).
- $captcha_instance->bg = array( '255', '255', '255' );
- // Font Size of CAPTCHA characters.
- $captcha_instance->font_size = '16';
- // Width between CAPTCHA characters.
- $captcha_instance->font_char_width = '15';
- // CAPTCHA image type. Can be 'png', 'jpeg', or 'gif'
- $captcha_instance->img_type = 'png';
- $captcha_instance_word = $captcha_instance->generate_random_word();
- $captcha_instance_prefix = mt_rand();
- $captcha_instance_image_name = $captcha_instance->generate_image($captcha_instance_prefix, $captcha_instance_word);
- $captcha_instance_image_url = get_bloginfo('wpurl') . '/wp-content/plugins/really-simple-captcha/tmp/';
- $captcha_instance_image_src = $captcha_instance_image_url.$captcha_instance_image_name;
- $captcha_instance_image_width = $captcha_instance->img_size[0];
- $captcha_instance_image_height = $captcha_instance->img_size[1];
- $captcha_instance_field_size = $captcha_instance->char_length;
- $captcha_instance_form_label = 'Anti-Spam:';
- ?>
- <p class="comment-form-captcha">
- <img src="<?php echo $captcha_instance_image_src; ?>" alt="captcha" width="<?php echo $captcha_instance_image_width; ?>" height="<?php echo $captcha_instance_image_height; ?>" />
- <label for="captcha_code"><?php echo $captcha_instance_form_label; ?></label>
- <input id="captcha_instance_code" name="captcha_instance_code" size="<?php echo $captcha_instance_field_size; ?>" type="text" />
- <input id="captcha_instance_prefix" name="captcha_instance_prefix" type="hidden" value="<?php echo $captcha_instance_prefix; ?>" />
- </p>
- ==================================
- ABOVE
- ==================================
- <div class="em-booking-buttons">
- <?php if( preg_match('/https?:\/\//',get_option('dbem_bookings_submit_button')) ): //Settings have an image url (we assume). Use it here as the button.?>
- ==================================
- PASTE THIS SNIPPET IN YOUR THEME FUNCTIONS.PHP
- ==================================
- function em_validate(){
- global $EM_Event,$EM_Notices;
- $captcha_instance = new ReallySimpleCaptcha();
- $captcha_instance_correct = false;
- $captcha_instance_prefix = $_POST['captcha_instance_prefix'];
- $captcha_instance_code = $_POST['captcha_instance_code'];
- $captcha_instance_check = $captcha_instance->check( $captcha_instance_prefix, $captcha_instance_code );
- $captcha_instance_correct = $captcha_instance_check;
- if ( !$captcha_instance_correct ){
- $EM_Notices->add_error('Invalid security code');
- return false;
- }
- return true;
- }
- add_filter('em_event_validate','em_validate');
- ==================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement