Delete Expired Orphan Child Entries (Instead of Trashing)

Experimental Snippet 🧪

Code

Filename: gpnf-delete-expired-orphans.php

<?php
/**
 * Gravity Perks // Nested Forms // Delete Expired Orphan Child Entries (Instead of Trashing)
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 *
 * Experimental Snippet 🧪
 */
add_action( 'gform_update_status', function( $entry_id, $new_status ) {
	if ( $new_status === 'trash' ) {
		$child_entry_expiration = gform_get_meta( $entry_id, GPNF_Entry::ENTRY_EXP_KEY );
		if ( $child_entry_expiration ) {
			GFAPI::delete_entry( $entry_id );
		}
	}
}, 10, 2 );

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.