Skip to content

Filters and Hooks

The Procaptcha plugin introduces new WordPress filters and hooks, allowing you to customize its behavior.

By default, Procaptcha is displayed only to unauthorized users.

To modify this behavior, use the is_captcha_present hook. For example, to make Procaptcha required for everyone, add the following code to your theme’s functions.php file:

add_filter('prosopo/procaptcha/is_captcha_present', '__return_true');`

You can customize the default error message by adding this code to your theme’s functions.php file:

add_filter('prosopo/procaptcha/validation_error_message', function (string $message): string {
return __('Custom error message', 'my-theme');
});

3. Customizing Procaptcha Attributes

Section titled 3. Customizing Procaptcha Attributes

Beyond the style preferences in the plugin settings, you can customize any supported Procaptcha data attributes using the prosopo/procaptcha/captcha_attributes filter.

add_filter('prosopo/procaptcha/captcha_attributes', function (array $attributes): array {
$attributes['lang'] = 'de';
return $attributes;
});

4. Forms with Procaptcha in Tests

Section titled 4. Forms with Procaptcha in Tests

If your tests involve forms with Procaptcha, you can bypass the Procaptcha by adding the following constant to your wp-config.php file:

define('PROSOPO_PROCAPTCHA_ALLOW_BYPASS', true);

In your tests, include an input[name=procaptcha-response] element with the value bypass to simulate Procaptcha completion.

Important: This bypass constant should only be used in development environments.