How can I find step ID / form ID / field IDs and use them in hooks?

When writing custom code/snippets to use with Gravity Forms or Gravity Flow, it is often required to tailor the code to target a specific form, workflow step or field. Each ID can be found in a different part of the Gravity Forms or Gravity Flow UI.

Finding the Form ID

You may want to use the Form ID in a hook to ensure the custom logic is only performed for specific form(s). See gravityflow_workflow_complete for one example such example in an action hook.

Form ID on the Form List

Form ID in the URL in the form editor

Form ID in the URL in the entry details screen

Finding the Field ID

You may want to use the Field ID in a hook to customize if fields are presented, such as with gravityflow_workflow_detail_display, or using/evaluating that entries’ field value in some other logic such as gravityflow_step_is_condition_met. Anywhere you see something like $entry[‘3’] in a snippet is referring to the value for field ID #3 of the current entry.

From editor screen

The field ID can most easily be found via the form editor screen. 

Browser developer tools

Browser Developer Tools window (usually F12) or view page source can also provide you the field ID

Finding the Step ID

You may want to use the Step ID in a hook to ensure the custom logic is only performed for specific step(s). This snippet comes from gravityflow_workflow_complete and shows how to check the step ID (1041) before modifying a field value based on the current user ID. 

1
2
3
4
5
6
7
8
9
add_action( 'gravityflow_step_complete', 'sh_gravityflow_step_complete', 10, 4 );
function sh_gravityflow_step_complete( $step_id, $entry_id, $form_id, $status ) {
    $current_user = wp_get_current_user();
    if ( $step && $step_id == 1041 ) { //step id is 1041
        $input_id = 2; //field id of the User field
        $value = $current_user->ID;
        GFAPI::update_entry_field( $entry_id, $input_id, $value );
    }
}

Step ID from workflow list

Step ID in the workflow steps list by mouseover the step title

Step settings page

Step object in code

1
$step->get_id() will get the step id