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
Parameter | Type | Definition |
---|---|---|
$target_entry_id | Integer | The entry ID step settings identified. |
$target_form_id | Integer | The form for the entry ID identified |
$entry | Entry | The current $entry |
$step | Step | The current step |
Examples
Locate the entry with the largest value in a separate form numeric field.
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?