b2evolution b2evolution

  • Sign in
  • Sign up
  • About
  • Downloads
  • Hosting
  • Docs
  • Support
  • Sign in
  • Sign up
  • Manuals Home
  • Latest Updates
 
  1. b2evolution CMS User Manual
  2. Developer Reference
  3. How to... (Customize)
  4. 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;
}
Created by mgsolipa • Last edit by fplanque on 2020-06-09 00:25 • •

No feedback yet

On this page

  • Contact form

Search the Manual

Content Hierarchy

  • b2evolution CMS User Manual
  • User's Guide
  • Installation / Upgrade
  • Front-office Reference
  • Back-office Reference
  • Developer Reference
    • Website Skins/Themes
    • Email Skins/Themes
    • b2evolution Files
    • Website Integration
    • Plugins
    • Debugging
    • Technical Reference
    • Hacks
    • Credits
    • Development
    • How to... (Customize)
      • How to upgrade a b2evo blog template to an evoSkin
      • Popup Comments
      • FTP 101: How to upload and manage files on your web server
      • Working with the Open Graph Protocol
      • How to - Use "honeypots" in your forms
      • I made a change but my blog is not updated
      • Turn A Skin Into A Template
      • Where is the Templates Tab?
      • Display Recent Posts In The Sidebar
      • Recent Comments In The Sidebar
      • Include Item Feedback
      • How to display comments, trackbacks and pingbacks UNMIXED
      • Change the way my blog looks
      • How to use b2evolution as a CMS
      • How to Show the Assigned Author of a post
      • How to change the "Read More" link
      • How to call a blog through xyz.php instead of index.php?blog=x
      • How to turn a Skin into a Template
      • How To use Pop-Up Comments in your evoSkin
      • How to add a smilie to your toolbar
      • How to display the posts' author
      • Dev Menu
    • Scheduled Tasks Reference
  • Operations Reference
  • Advanced Topics
  • Glossary
  • Archives
Build your own website!

This online manual is powered by b2evolution CMS – A complete engine for your website.

About b2evolution

  • What is it?
  • Features
  • Getting Started
  • Screenshots
  • Online demo
  • Testimonials
  • Design philosophy
  • Free & open source
  • Terms of service

Downloads

  • Latest releases
  • Skins
  • Plugins
  • Language packs

About us

  • About us
  • Contact

Webhosting Guide

  • Web hosting blog
  • Best web hosting
  • Cheap web hosting
  • Green web hosting
  • Hosting with SSH
  • VPS hosting
  • Dedicated servers
  • Reseller hosting
  • Int'l: UK / France

Docs & Support

  • Online manual
  • Forums
  • Hire a pro !

Other

  • Adsense
  • Press room
  • Privacy policy

Stay in touch

  • GitHub
  • Twitter
  • Facebook
  • LinkedIn
  • News blog
  • RSS feed
  • Atom feed

Founded & Maintained by François Planque