spivurno
3/22/2017 - 2:10 PM

Gravity Perks // GP Unique ID // Map Multiple Conditional Unique IDs to a Single Field

Gravity Perks // GP Unique ID // Map Multiple Conditional Unique IDs to a Single Field

<?php
/**
 * Gravity Perks // GP Unique ID // Map Multiple Conditional Unique IDs to a Single Field
 * http://gravitywiz.com
 */
// update the "123" to your form ID
add_filter( 'gform_entry_post_save_123', function( $entry ) {

	// update to your Unique ID field IDs
	$uid_field_ids = array( 2, 3, 4 );

	// update "1" to the input that will be used to the conslidated Unique ID
	$copy_to_field_id = 1;

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

	GFAPI::update_entry( $entry );

	return $entry;
} );