The gform_progress_bar filter allows you to modify or replace the default Gravity Forms progress bar for multi-page forms.
Usage
Apply to all forms:
add_filter( 'gform_progress_bar', 'my_custom_function', 10, 3 );
Apply to specific forms:
// template add_filter( 'gform_progress_bar_{formId}', 'my_custom_function', 10, 3 );
// target form ID 1
add_filter( ‘gform_progress_bar_1’, ‘my_custom_function’, 10, 3 );
Parameters
- $progress_bar (string): Progress bar markup as an HTML string.
- $form (Form Object): Current Form object.
- $confirmation_message (string): The confirmation message to be displayed on the confirmation page.
More information
See Gravity Forms Docs: gform_progress_bar
Examples
Generate custom progress bar markup
Create a custom progress bar with a specific HTML structure:
add_filter( 'gform_progress_bar', function( $progress_bar, $form, $confirmation_message ) { $progress_bar = '<ul> <li>Page 1</li> <li>Page 2</li> <li>Page 3</li> </ul>';
return $progress_bar;
}, 10, 3 );
Replace “Step” with “Level”
Change the progress bar label from “Step” to “Level”:
add_filter( 'gform_progress_bar', function( $progress_bar, $form, $confirmation_message ) { $progress_bar = str_replace( 'Step', 'Level', $progress_bar ); return $progress_bar; }, 10, 3 );
Hide progress bar on the last page
Hide the progress bar when the user reaches the last page of the form:
add_filter( 'gform_progress_bar', function( $progress_bar, $form, $confirmation_message ) { if ( $form['pageNumber'] == count( $form['pages'] ) ) { $progress_bar = ''; } return $progress_bar; }, 10, 3 );
Add custom CSS class to progress bar
Add a custom CSS class to the progress bar:
add_filter( 'gform_progress_bar', function( $progress_bar, $form, $confirmation_message ) { $progress_bar = str_replace( 'gf_progressbar', 'gf_progressbar my_custom_class', $progress_bar ); return $progress_bar; }, 10, 3 );
Modify progress bar for specific form
Modify the progress bar only for a specific form with ID 1:
add_filter( 'gform_progress_bar_1', function( $progress_bar, $form, $confirmation_message ) { // your custom code here return $progress_bar; }, 10, 3 );