Atenção!

Este artigo contém código PHP e destina-se a desenvolvedores. Oferecemos este código como uma cortesia, mas não fornecemos suporte para personalizações de código ou desenvolvimento de terceiros.

Para orientação extra, consulte o tutorial do WPBeginner sobre como adicionar código personalizado.

Dispensar

Descrição

The wpforms_math_captcha filters setting properties are applied to the Custom Captcha field in WPForms.

Parâmetros

$settings
(array) (Required) Minimum integer, maximum integer, and operators that will be used.

Fonte

wpforms-captcha/src/Plugin.php

Mais Informações

The wpforms_math_captcha filter is applied to an array that sets minimum and maximum numbers, as well as the type of calculations used with those values (addition, multiplication, etc). It can be used to change the integer range and operators allowed in a custom captcha field.

Exemplo

/**
 * Filters setting properties applied to the Custom Captcha addon.
 *
 * @link   https://wpforms.com/developers/wpforms_math_captcha/
 *
 * @param  array $settings Minimum integer, maximum integer, and operators that will be used.
 * @return array
 */

function wpf_dev_math_captcha_settings( $settings ) {
     
    /* Default settings
        array(
            'min' => 1,
            'max' => 15,
            'cal' => array( '+', '*', '-' ),
        );
     */
 
    // Use addition only for easier math
    // Use the minimum number of 1
    // Use the maximum number of 10
    $settings[ 'cal' ] = [ '+' ];
	$settings[ 'min' ] = [ '1' ];
	$settings[ 'max' ] = [ '10' ];
 
    return $settings;
}

add_filter( 'wpforms_math_captcha', 'wpf_dev_math_captcha_settings', 30, 1 );

Artigos de Referência

Change the Captcha Math for the Custom Captcha Field