How to Change the Expiry Date On Partial Entries

Would you like to change the expiry date on partial entries when using the Save and Resume addon? Using a small snippet, you can easily change the default setting when these partial entries are removed to meet the needs of your business. In this useful article, we’re going to show you how to achieve this using a PHP filter.

By default, partial entries are automatically removed from your entries after 30 days.

Creating the form

To begin, you’ll create your form and add your fields. You’ll then need to enable the Save and Resume settings for your form.

after adding your fields, go to Settings and the Save and Resume tab to toggle on Save and Resume for this form

For any assistance with creating this type of form, please check out this helpful guide.

Changing the expiry date

Now it’s time to add the snippet to your site. If you need any assistance on how and where to add snippets to your site, please review this tutorial.

/*
 * Set the number of days to delete partial entries when using the Save and Resume addon
 *
 * @link https://wpforms.com/developers/how-to-change-the-expiry-date-on-partial-entries/
 */

function wpf_dev_delete_expired_entries( $expire_period ) {
 
    // deleted partial entries after 15 days
    return '-15 days'; 

}

add_filter( 'wpforms_save_resume_tasks_deleteexpiredentriestask_expire_period', 'wpf_dev_delete_expired_entries', 10, 1 );

The snippet above will overwrite the default setting of 30 days to remove partial entries and now change it to 15 days.

And that’s all you need to change the expiry date for partial entries! Would you like to change the email subject line for Save and Resume email notifications? Check out the tutorial on How to Change the Email Subject on Save and Resume Email Notifications.

Reference Filter

wpforms_save_resume_tasks_deleteexpiredentriestask_expire_period

FAQ

Q: Why do I still see my partial entries?

A: When altering the expiry period with this filter, it may become necessary to manually run the task associated with removing these entries. In order to do this, navigate to your WordPress admin WPForms » Tools » Scheduled Actions, and from the Pending section, look for the wpforms_save_resume_clean action. Under this task, you’ll see an option to Run or Cancel. Select Run to manually run this task and remove these partial entries.

remember to run the task to purge these partial entries manually after you alter the default settings of this filter

This will manually trigger the task to run and remove these partial entries for you.

Q: Will this always have to be in days?

A: Not at all, you can certainly use minutes if you’d like by using this snippet.

/*
 * Set the number of days to delete partial entries when using the Save and Resume addon
 *
 * @link https://wpforms.com/developers/how-to-change-the-expiry-date-on-partial-entries/
 */

function wpf_dev_delete_expired_entries( $expire_period ) {
 
    // delete partials after 1 minute
    return '-60 seconds'; 

}

add_filter( 'wpforms_save_resume_tasks_deleteexpiredentriestask_expire_period', 'wpf_dev_delete_expired_entries', 10, 1 );