Riassunto AI
Descrizione
Il filtro wpforms_form_token_check_after_today viene utilizzato per estendere i tempi di cache utilizzati per il token del modulo.
Parametri
- $times
- (array) Un array di tempi da controllare dopo oggi.
Origine
wpforms/src/Forms/Token.php
Maggiori Informazioni
Il filtro wpforms_form_token_check_after_today può essere utilizzato per estendere i tempi di cache che WPForms utilizza sui token del modulo per i tempi successivi.
Questo filtro viene utilizzato principalmente per gestire casi limite come il caricamento e l'invio della pagina del modulo in due giorni diversi.
È disponibile anche un altro filtro per estendere i tempi di cache in precedenza. Si prega di consultare il filtro wpforms_form_token_check_before_today.
Esempio
/**
* 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' );
Correlati
Riferimento articolo: Come modificare il tempo di cache sul token del tuo modulo
Riferimento filtro aggiuntivo: wpforms_form_token_check_before_today