Title: Changing form token cache time
Last modified: May 3, 2022

---

# Changing form token cache time

 *  Resolved [alexbosch](https://wordpress.org/support/users/alexbosch/)
 * (@alexbosch)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/changing-form-token-cache-time/)
 * Hi;
 * I was searching a way to solve the incompatibility of cache time of your token
   and my cache plugin and I found this article on your website:
 * [https://wpforms.com/developers/how-to-change-the-cache-time-on-your-form-token/](https://wpforms.com/developers/how-to-change-the-cache-time-on-your-form-token/)
 * I want to apply that, but I don’t understand exactly what I have to write on 
   the php inserter. If I want to allow a token cache for one week, should I use
   the next code?
 *     ```
       add_filter( 'wpforms_form_token_check_before_today', 'example_add_longer_token_time_before' );
   
           /**
            * Extend the expiration time. 
            */
           function example_add_longer_token_time_before( $times ) {
               // Allow the token to persist for 5 days
               $times[] = 7 * DAY_IN_SECONDS;
           }
       ```
   
 * If not, could you please help me to solve that.
 * Thank you in advance.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Prashant Rai](https://wordpress.org/support/users/prashantrai/)
 * (@prashantrai)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/changing-form-token-cache-time/#post-15619611)
 * Hey [@alexbosch](https://wordpress.org/support/users/alexbosch/),
 * Thanks for contacting us!
 * You can use following code to extend the expiration time:
 *     ```
       add_filter( 'wpforms_form_token_check_before_today', function ( $times ) {  
   
          $times[] = 3 * DAY_IN_SECONDS;  
          $times[] = 4 * DAY_IN_SECONDS;  
          $times[] = 5 * DAY_IN_SECONDS;  
          $times[] = 6 * DAY_IN_SECONDS;  
          $times[] = 7 * DAY_IN_SECONDS;  
          $times[] = 8 * DAY_IN_SECONDS;  
   
       return $times; } );
       ```
   
 * The above code would increase the token lifetime to 8 days and that should also
   fix the issue for you.
 * Kindly,
 *  Thread Starter [alexbosch](https://wordpress.org/support/users/alexbosch/)
 * (@alexbosch)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/changing-form-token-cache-time/#post-15620938)
 * Hi [@prashantrai](https://wordpress.org/support/users/prashantrai/)
 * OK. I’ll try that.
 * Thank you so much!
 *  [Prashant Rai](https://wordpress.org/support/users/prashantrai/)
 * (@prashantrai)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/changing-form-token-cache-time/#post-15629514)
 * You’re most welcome [@alexbosch](https://wordpress.org/support/users/alexbosch/)
   🙂
 *  [Prashant Rai](https://wordpress.org/support/users/prashantrai/)
 * (@prashantrai)
 * [4 years ago](https://wordpress.org/support/topic/changing-form-token-cache-time/#post-15650598)
 * Hey [@alexbosch](https://wordpress.org/support/users/alexbosch/) – We haven’t
   heard back from you in about a week, so I’m going to go ahead and close this 
   thread for now. But if you’d like us to assist further, please feel welcome to
   continue the conversation.
 * Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Changing form token cache time’ is closed to new replies.

 * ![](https://ps.w.org/wpforms-lite/assets/icon.svg?rev=3254748)
 * [WPForms - Easy Form Builder for WordPress - Contact Forms, Payment Forms, Surveys, & More](https://wordpress.org/plugins/wpforms-lite/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpforms-lite/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpforms-lite/)
 * [Active Topics](https://wordpress.org/support/plugin/wpforms-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpforms-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpforms-lite/reviews/)

## Tags

 * [cache](https://wordpress.org/support/topic-tag/cache/)
 * [token](https://wordpress.org/support/topic-tag/token/)

 * 4 replies
 * 2 participants
 * Last reply from: [Prashant Rai](https://wordpress.org/support/users/prashantrai/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/changing-form-token-cache-time/#post-15650598)
 * Status: resolved