Set Orphaned Entry Expiration Duration

Modify how long entries submitted from a nested form should be saved before being moved to the trash.

Code

Filename: gpnf-set-orphaned-entry-expiration-duration.php

<?php
/**
 * Gravity Perks // Nested Forms // Set Orphaned Entry Expiration Duration
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 *
 * Modify how long entries submitted from a nested form should be saved before being moved to the trash.
 */
// Expire orphaned entries after 30 days (1 month).
add_filter( 'gpnf_expiration_modifier', function() {
	return MONTH_IN_SECONDS;
} );

// Never expire orphaned entries.
add_filter( 'gpnf_expiration_modifier', function() {
	return 100 * YEAR_IN_SECONDS;
} );

Comments

  1. David Wever
    David Wever December 10, 2024 at 3:44 pm

    Is there a way to adjust not just the expiration modifier, but also the frequency that those entries are removed?

    I want to set orphaned entries to be removed after 15 minutes, but they won’t disappear until the daily removal of expired entries.

    Under the “What happens to child entries when the parent entry is never submitted?” header, I found the following: Expired entries are trashed daily.

    I want to make it more frequent than this. Let me know if there is a solution for this.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.