Description
The wpforms_form_token_check_after_today
filter is used to extend the cache times used for the form token.
Parameters
- $times
- (array) An array of times to check after today.
Source
wpforms/src/Forms/Token.php
More Information
The wpforms_form_token_check_after_today
filter can be used to extend the cache times that WPForms uses on the form tokens for the after times.
This filter is used mostly to catch edge cases like the form page loading and submitting on two different days.
There is another available filter for extending the cache times before as well. Please see the wpforms_form_token_check_before_today
filter.
Example
/** * 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' );
Related
Article Reference: How to Change the Cache Time on Your Form Token
Additional Filter Reference: wpforms_form_token_check_before_today