- b2evolution CMS User Manual
 - Developer Reference
 - How to... (Customize)
 - How to - Use "honeypots" in your forms
 
How to - Use "honeypots" in your forms
This manual is made only for version 5.0.6
Contact form
This modifications add a hidden field to your contact and messages forms. This field is supposed to be empty everytime, otherwise, we could suspect that the user is not as human as we want ;), and return an error that makes impossible to send the message.
File: /blogs/inc/_core/_param.funcs.php
/**
 * @param string param name
 * @param string error message
 * @param string|NULL error message for form field ($err_msg gets used if === NULL).
 * @return boolean true if OK
 */
function param_check_empty( $var, $err_msg = NULL, $field_err_msg = NULL )
{
	if( !empty( $GLOBALS[$var] ) )
	{
		if( empty($err_msg) )
		{
			$err_msg = sprintf( T_('The field «%s» should be empty.'), substr( $var, strpos( $var, '_' )+1 ) );
			$field_err_msg = T_('This field should be empty.');
		}
		if( $err_msg == '#' )
		{
			$err_msg = '';
		}
		param_error( $var, $err_msg, $field_err_msg );
		return false;
	}
	return true;
}
File: /blogs/inc/messaging/views/_thread.form.php
//Honeypot input field - the name of this field could be replaced by anyother, but consider that use something related with "honey" will be inefective
$Form->text_input( 'custom_input_field', '', 20, '', '', array('maxlength'=>100, 'style'=>'width: 100%;', 'id'=>'id_custom_input_field') );
File: /blogs/inc/messaging/model/_thread.class.php
		//Honeypot - Do not return any error message, if you would like to, uncomment the following line AND comment the line after that
		//$honey_pot_error_msg = T_('You must be human!');
		$honey_pot_error_msg = '';
		param( 'custom_input_field', 'string' );
		param_check_empty( 'custom_input_field', $honey_pot_error_msg );
After you have seen how this modifications work, please add the following CSS rule to your current skin. It also could be added to the main CSS file /blogs/rsc/basic.css in order to make it available all across the site, no matter which skin are you currently using in a particular collection. In this case, we will use evoPress as our current skin.
File: /blogs/skins/evopress/style.css
#id_custom_input_field {
	display: none;
}