gravityflowformconnector_target_entry_id

Description

The filter gravityflowformconnector_target_entry_id can be used to change the target entry of the Form Connector Update Fields Step. To do similar for the Update an Entry step type use gravityflowformconnector_update_entry_id.

Parameters

ParameterTypeDefinition
$target_entry_id IntegerThe entry ID step settings identified.
$target_form_idIntegerThe form for the entry ID identified
$entryEntryThe current $entry
$stepStepThe current step

Examples

Locate the entry with the largest value in a separate form numeric field. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
add_filter( 'gravityflowformconnector_target_entry_id', 'search_best_price_entry', 10, 5 );
function search_best_price_entry( $target_entry_id, $target_form_id, $entry, $form, $step ) {
  
    $search_criteria['field_filters']['mode'] = 'all';
    $sorting = array( 'key' => 1, 'direction' => 'DESC', 'is_numeric' => true );
    $paging = array( 'offset' => 0, 'page_size' => 1 );
    $entries = GFAPI::get_entries( 8, $search_criteria, $sorting, $paging );
 
    if( $entries ) {
        foreach( $entries as $entry ) {
            return $entry['id'];
        }
    }
 
    return $target_entry_id;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?