ご注意!

この記事には PHP コードが含まれており、開発者を対象としています。このコードは便宜上提供していますが、コードのカスタマイズやサードパーティの開発についてはサポートを提供していません。

追加のガイダンスについては、WPBeginner の カスタムコードの追加方法に関するチュートリアル を参照してください。

閉じる

説明

wpforms_math_captchaフィルターの設定プロパティは、WPFormsのカスタムキャプチャフィールドに適用されます。

パラメーター

$設定
(配列) (必須) 最小整数、最大整数、および使用される演算子。

ソース

wpforms-captcha/src/Plugin.php

詳細情報

wpforms_math_captchaフィルターは、最小値と最大値、およびそれらの値(加算、乗算など)で使用される計算の種類を設定する配列に適用されます。カスタムキャプチャフィールドで使用できる整数の範囲と演算子を変更するために使用できます。

/**
 * 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 );

参考記事

カスタムキャプチャフィールドのキャプチャ計算を変更する