Registration honeypot

A hidden “honeypot” field in your registration form is a great way to catch out signup bots and scripts – a bot or script will blindly enter text into the field, but humans won’t see it and, therefore, won’t ;-)

Add the following to your (child) theme’s functions.php:

function add_honeypot() {
    echo '
'; } add_action('bp_after_signup_profile_fields','add_honeypot'); function check_honeypot() { if (!empty($_POST['system55'])) { global $bp; wp_redirect(home_url().'/spam-prevention'); exit; } } add_filter('bp_core_validate_user_signup','check_honeypot');

That’s it! Don’t forget to add a page with the slug “spam-prevention” to your site which explains to the user that they did something that looks spammy…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>