I'm working on a WordPress plugin that extends Gravity Forms. I need to add some functionality to check for duplicate entries. I'm using GFAPI::get_entries( $form_id, $search_criteria ); to find and list all entries associated with my Gravity form that meet a certain search criteria. Here's a snippet of the code:
// Fetch field_ids, establish search criteria
$first_id = $last_id = $address_id = 0;
foreach ( $form['fields'] as $field ) {
if ( $field->get_input_type() == 'name' ) {
$first_id = $field->id . '.3';
$last_id = $field->id . '.6';
break;
}
}
foreach ( $form['fields'] as $field ) {
if ( $field->get_input_type() == 'address' ) {
$address_id = $field->id . '.1';
break;
}
}
$search_criteria['field_filters'] = array(
array( 'key' => $first_id, 'value' => $data['voterdata_FirstName'] ),
array( 'key' => $last_id, 'value' => $data['voterdata_LastName'] ),
array( 'key' => $address_id, 'value' => $data['voterdata_VoterAddress'] )
);
$search_criteria['status'] = 'active';
$entries = GFAPI::get_entries( $form_id, $search_criteria );
A var_dump(); of $entries returns all entries for my form that meet the search criteria. If more than one entry exists containing the same first name, last name, and address combination, I want to redirect my users to another page so that they may confirm which entry belongs to them. What is the best approach to checking $entries for duplicates?
Thanks in advance,