Description
The gravityflow_step_settings_fields filter allows new settings to be added existing step types or modify existing.
Parameters
Parameter | Type | Details |
---|---|---|
$settings | Array | The current steps settings fields array. |
$current_step_id | Integer | The current step ID |
Examples
Add a language setting to Gravity Flow PDF Generator steps
This example will let a specific language be defined in the step settings which the gravityflowpdf_content filter could read to provide PDF content in the desired language for output.
add_filter( 'gravityflow_step_settings_fields', 'step_settings_pdf_language', 10, 2 );
function step_settings_pdf_language( $settings, $current_step_id ) {
$step = gravity_flow()->get_step( $current_step_id );
if ( $step && $step->get_type() == 'pdf' ) {
//Ensure the new setting is added into the 'PDF' section of the existing settings.
$pdf_settings_index = array_search( 'PDF', array_column( $settings, 'title' ) );
if ( $pdf_settings_index ) {
$settings[$pdf_settings_index]['fields'][] = array(
'name' => 'pdf_language',
'label' => 'PDF Language',
'type' => 'select',
'choices' => array(
array( 'label' => 'English', 'value' => 'en' ),
array( 'label' => 'Swedish', 'value' => 'sv' ),
),
);
}
}
return $settings;
}
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?