spivurno
9/13/2016 - 2:18 PM

Gravity Perks // GP Unique ID // Copy ID to Another Field

Gravity Perks // GP Unique ID // Copy ID to Another Field

/**
 * Gravity Perks // GP Unique ID // Copy ID to Another Field
 * http://gravitywiz.com
 */
// update the "123" to your form ID
add_filter( 'gform_entry_post_save_123', 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, 3 );

	foreach( $copy_to_field_ids as $copy_to_field_id ) {
		$entry[ $copy_to_field_id ] = $entry[ $uid_field_id ];
	}

	GFAPI::update_entry( $entry );

	return $entry;
} );