Last active
October 13, 2018 08:18
-
-
Save rafaehlers/1446dcac5db5b3b289e6b379f6107b3d to your computer and use it in GitHub Desktop.
Copy the Unique ID to another field
This file contains hidden or 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 // GP Unique ID // Copy ID to Another Field | |
| * http://gravitywiz.com | |
| */ | |
| // change the "999" to your form ID | |
| add_filter( 'gform_entry_post_save_999', function( $entry ) { | |
| // update "1" to your Unique ID field's field ID | |
| $uid_field_id = 1; | |
| // update "2" and "3" to whatever field IDs you would like to copy the unique ID, if you only need one, format it like this: array( 2 ) | |
| $copy_to_field_ids = array( 2 ); | |
| foreach( $copy_to_field_ids as $copy_to_field_id ) { | |
| $entry[ $copy_to_field_id ] = 'http://mywebsite.com/'.$entry[id].'/'.$entry[ $uid_field_id ]; | |
| } | |
| GFAPI::update_entry( $entry ); | |
| return $entry; | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment