Description
Use the filter gravityflow_workflow_detail_display_field to hide specific fields on the workflow detail page.
Parameters
Parameter | Type | Details |
---|---|---|
$display | Boolean | Display a specific field yes/no |
$field | Field | The field |
$form | Form | The current form |
$entry | Entry | The current entnry |
$current_step | Step | The current workflow step |
Examples
Hide a specific field when on a specific step.
// Hide field ID 4 when on step ID 88
add_filter( 'gravityflow_workflow_detail_display_field', 'sh_gravityflow_workflow_detail_display_field', 10, 5 );
function sh_gravityflow_workflow_detail_display_field( $display, $field, $form, $entry, $current_step ) {
if ( $current_step && $current_step->get_id() == 88 && $field->id == 4 ) {
$display = false;
}
return $display;
}
Hide all fields on Form 1 except fields 4, 5, and 6.
// Hide all fields except fields 4 on Form 1
add_filter( 'gravityflow_workflow_detail_display_field', 'sh_gravityflow_workflow_detail_display_field', 10, 5 );
function sh_gravityflow_workflow_detail_display_field( $display, $field, $form, $entry, $current_step ) {
if ( $form['id'] == 1 ) {
if ( in_array( $field->id, array( 4, 5, 6 ) ) ) {
$display = true;
} else {
$display = false;
}
}
return $display;
}
Conditionally display certain fields based on overall workflow and certain step statuses.
This example will display all fields (field ID 1 – 4 assumed) if workflow steps id 256 and 257 are complete and the workflow is complete. If step 257 were rejected / skipped via Admin actions only filed ids 1 and 2 will be displayed on workflow complete status.
If the workflow is not complete it will return whatever value has been defined in step settings (including the complete step settings).
add_filter( 'gravityflow_workflow_detail_display_field', 'sh_gravityflow_workflow_detail_display_field', 10, 5 );
function sh_gravityflow_workflow_detail_display_field( $display, $field, $form, $entry, $current_step ) {
if ( $entry['workflow_final_status'] == 'complete' ) {
if ( $entry['workflow_step_status_256'] == 'complete' && $entry['workflow_step_status_257'] == 'complete') {
$display = true;
} else if ( $entry['workflow_step_status_256'] == 'complete' ) {
if ( in_array( $field->id, array( 1, 2 ) ) ) {
$display = true;
}
else {
$display = false;
}
}
}
return $display;
}
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?