AI要約
説明
wpforms_form_token_check_before_today フィルターは、フォームトークンに使用されるキャッシュ時間を延長するために使用されます。
パラメーター
- $times
- (array) 今日の前でチェックする時間の配列。
ソース
wpforms/src/Forms/Token.php
詳細情報
wpforms_form_token_check_before_today フィルターは、WPForms がフォームトークンの前の時間に使用するキャッシュ時間を延長するために使用できます。
このフィルターは、主にフォームページがロードされ、異なる 2 日間で送信されるようなエッジケースをキャッチするために使用されます。
後でキャッシュ時間を延長するための別のフィルターも利用可能です。 wpforms_form_token_check_after_today フィルターを参照してください。
例
/**
* Extend cache time on form tokens before today.
*
* @param array $times An array of times to check before today.
* @return array
*/
function example_add_longer_token_time_before( $times ) {
// Allow the token to persist for 3, 4, and 5 days
$times[] = 3 * DAY_IN_SECONDS;
$times[] = 4 * DAY_IN_SECONDS;
$times[] = 5 * DAY_IN_SECONDS;
return $times;
}
add_filter( 'wpforms_form_token_check_before_today', 'example_add_longer_token_time_before' );
/**
* Extend cache time on form tokens after today.
*
* This filter is to catch edge cases of someone loading the form and submitting,
* with the expiration happening in between. Making this longer allows for more leeway.
*
* @param array $times An array of times to check after today.
* @return array
*/
function example_add_longer_token_time_after( $times ) {
// Allow the token to persist for 1 day
$times[] = DAY_IN_SECONDS;
return $times;
}
add_filter( 'wpforms_form_token_check_after_today', 'example_add_longer_token_time_after' );
関連
記事の参照: フォームトークンのキャッシュ時間を変更する方法
追加フィルター参照: wpforms_form_token_check_after_today