Created
January 23, 2020 14:47
-
-
Save spivurno/f30988968900333c631e81a9c873358a to your computer and use it in GitHub Desktop.
Gravity Perks // Easy Passthrough // Save EP Token to Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gravity Perks // Easy Passthrough // Save EP Token to Field | |
* http://gravitywiz.com/documentation/gravity-forms-easy-passthrough/ | |
* | |
* This snippet allows you to populate the EP token into a field so it can be mapped in Gravity Forms feeds. The filter | |
* fires before feeds are processed so the token is available in time. | |
*/ | |
// Update "123" to your form ID. | |
add_filter( 'gform_entry_post_save_123', function( $entry, $form ) { | |
// Update "4" to the ID of the field you woule like to populate with the EP token. | |
$target_field_id = 4; | |
if( is_callable( 'gp_easy_passthrough' ) ) { | |
$token = gp_easy_passthrough()->get_entry_token( $entry ); | |
GFAPI::update_entry_field( $entry['id'], $target_field_id, $token ); | |
$entry[ $target_field_id ] = $token; | |
} | |
return $entry; | |
}, 5, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gp-easy-passthrough/gpep-save-token-to-field.php