Delete Token After Use

Delete the EP token that was used to populate a given form after that form is submitted.

Code

Filename: gpep-delete-token-after-use.php

<?php
/**
 * Gravity Perks // Easy Passthrough // Delete Token After Use
 * https://gravitywiz.com/documentation/gravity-forms-easy-passthrough/
 *
 * Delete the EP token that was used to populate a given form after that form is submitted.
 */
add_filter( 'gform_after_submission', function() {
	if ( rgget( 'ep_token' ) && is_callable( 'gp_easy_passthrough' ) ) {
		$entry = gp_easy_passthrough()->get_entry_for_token( rgget( 'ep_token' ) );
		if ( $entry ) {
			gform_delete_meta( $entry['id'], 'fg_easypassthrough_token' );
		}
	}
} );

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.