Skip to content
OSULZER.AT
Security3 min read· updated February 14, 2026

Protect Bricks Builder Forms Against Spam with a GDPR-Compliant Honeypot

Protect Bricks Builder forms from spam without reCAPTCHA. Since version 1.7.1 a new filter lets you add a GDPR-compliant honeypot field with a little PHP.

Bricks Builder for WordPress is a really great alternative to heavyweights like Elementor, but one downside is that in some areas it does not have as many extensions as Elementor does. One of the pain points so far was spam protection for forms. Out of the box, you can only work with Google reCAPTCHA and similar services, which is a problem with regard to the GDPR. Since version 1.7.1, however, Bricks Builder offers a new filter that lets us validate forms ourselves, for example to build our own honeypot fields. Below you will find a basic approach for a GDPR-compliant honeypot field.

Setting Up the Honeypot Field

In the Bricks form builder, you have to create a hidden field with the name attribute “osu_honeypot”.

PHP Code for WordPress

Add the following code to the functions.php of your child theme or to a plugin of your own:

add_filter( 'bricks/form/validate', function( $errors, $form ) {
  $form_settings = $form->get_settings();
  $form_fields   = $form->get_fields();
  $form_id       = $form_fields['formId'];

	if(!isset( $form_fields['osu_honeypot'] ) || intval($form_fields['osu_honeypot']) < 10 ) {
		$errors[] = 'Es gab einen Fehler bei der Verarbeitung Ihrer Anfrage, bitte wenden Sie sich direkt an uns.';
	}

  return $errors;
}, 10, 2 );

JavaScript Code

Add this code to your theme or a custom script to automatically fill the honeypot field with a time value:

document.addEventListener("DOMContentLoaded", function () {
    let secondsElapsed = 0;
    const inputField = document.querySelector("input[name='osu_honeypot']");

    if (!inputField) {
        console.warn("Input field with name 'osu_honeypot' not found.");
        return;
    }

    function updateTime() {
        secondsElapsed++;
        inputField.value = secondsElapsed;
    }

    setInterval(updateTime, 1000);
});

How It Works

  1. A visitor arrives on the website → The JavaScript starts counting the seconds the visitor spends on the page. Every second, the value of the hidden field osu_honeypot is updated.

  2. Normal visitors usually need longer than 10 seconds to find the form, fill it out, and submit it. Spambots, on the other hand, often fill it out in just a few seconds.

  3. The honeypot field is deliberately named as such to tempt bots into not filling it out. In addition, the value is set via JavaScript, which most spambots do not execute.

This method can effectively block many spambots without bothering users with captchas or other cumbersome methods. The solution here is of course not perfect yet, but it is a good starting point for further optimization. If you implement this solution, all form fields you build with Bricks must include the form field “osu_honeypot”, otherwise you will always get an error message.

Learn more about my services as a WordPress developer.

Photo by Pau Casals on Unsplash

WordPress Maintenance

So it never comes to that

Tested updates, daily backups, and malware protection - from €40 per month.

See maintenance

New project?

Contact.

Tell me briefly about your project - I'll get back to you personally.

Your data is used solely to handle your inquiry. More in the privacy policy.