New Inspiro AI Demo Generator — can't find the perfect demo? Describe your website and AI builds a custom one in about 2 minutes. Learn more →

Knowledge Base

Documentation

Theme Documentation



Plugin Documentation



Resources

Developer Reference: Hooks and Functions

This article refers to WPBruiser

WPBruiser 3.3 introduced a small extension API. It’s what WPBruiser Pro uses to add its integrations, and you can use it to protect a custom form, supply your own IP-to-country data or add your own rejection rules. This reference lists the public functions, filters and actions of the free plugin and of WPBruiser Pro.


Table of Contents

  1. Protecting a custom form
  2. Functions
  3. Filters and actions in WPBruiser
  4. Filters in WPBruiser Pro
  5. The wpbruiser:token browser event

Protecting a custom form

A protected form needs two things: the hidden token field inside the form, and a check when the form is submitted. The functions below handle both. They take a module name and an option name, which identify the switch that turns protection on and the form shown in Reports; register your own module through the wpbruiser_register_modules filter (documented in GdbcModulesController::registerExtensionModules() in the plugin’s code) or reuse an existing one.

// 1. Print the token field inside your form.
add_action( 'my_form_fields', function () {
    echo wpbruiser_get_token_field_html(); // already escaped
} );

// 2. Check the submission in your form's validation step.
add_filter( 'my_form_is_spam', function ( $is_spam, $fields ) {
    if ( ! function_exists( 'wpbruiser_verify_submission' )
        || ! wpbruiser_is_option_enabled( 'MyModule', 'IsMyFormActivated' ) ) {
        return $is_spam;
    }
    return wpbruiser_verify_submission( 'MyModule', 'IsMyFormActivated', $fields ) ? $is_spam : true;
}, 10, 2 );

Wrap your code in function_exists() checks so your form keeps working when WPBruiser is deactivated.


Functions

Function Returns
wpbruiser_get_extension_api_version() The extension API version (int).
wpbruiser_get_token_field_html() The escaped markup of the hidden token field. Also makes sure WPBruiser’s script is loaded on the page.
wpbruiser_is_option_enabled( $module, $option ) Whether protection is switched on for that module option.
wpbruiser_verify_submission( $module, $option, $notes = array() ) true if the current request passes every check. On failure the attempt is logged, with $notes as the submitted content shown in Reports. The result is decided once per request. An unknown module name lets the submission through (and triggers a _doing_it_wrong notice), so a typo never locks visitors out.
wpbruiser_get_token_field_names() The names of the token fields, so you can remove them from stored submissions, or copy them into $_POST when your form sends JSON.

Filters and actions in WPBruiser

Hook Type Use
wpbruiser_loaded action Fires once WPBruiser is running; receives the extension API version.
wpbruiser_register_modules filter Add module definitions for your own integrations.
wpbruiser_reject_reason filter Reject a submission that passed every check. Return a GdbcRequestController::REJECT_REASON_* constant, or null to accept. Receives the attempt entity. WPBruiser Pro’s rate limits use it.
wpbruiser_country_id_for_ip filter Replace the bundled IP-to-country lookup; receives the country ID and the IP address.
wpbruiser_scripts_in_head filter Return true to load WPBruiser’s script in the page head instead of the footer.
wpbruiser_pro_version filter Lets an add-on announce itself; WPBruiser hides its Pro upsells when it returns a version.

Filters in WPBruiser Pro

Hook Use
wpbruiser_pro_rejection_message Change the message visitors see when a submission is blocked.
wpbruiser_excluded_gforms Array of Gravity Forms form IDs to leave unprotected.
wpbruiser_pro_load_module Return false to stop a Pro module from loading; receives whether it would load and the module name.

Examples for the first two are in Form Builder and Newsletter Integrations.


The wpbruiser:token browser event

When WPBruiser’s script fills a form’s token fields, it fires a wpbruiser:token event on the form. The event bubbles, and event.detail.fields holds the token fields. Use it if your form builds its own request, for example as JSON, and needs to include the token:

document.addEventListener( 'wpbruiser:token', function ( event ) {
    console.log( event.target, event.detail.fields );
} );

What’s Next?

Last updated on October 17, 2026