The gform_progressbar_start_at_zero filter allows you to change the progress bar on multi-page forms to start at zero percent.
Usage
Add the following code to your functions.php file:
add_filter('gform_progressbar_start_at_zero', '__return_true');
Parameters
- No parameters are required for this filter.
More Information
See Gravity Forms Docs: gform_progressbar_start_at_zero
This filter was added in Gravity Forms version 1.6.3 and can be found in the form_display.php file within the GFFormDisplay::get_form() and GFFormDisplay::get_progress_bar() methods.
Examples
Set progress bar to start at zero
This example sets the progress bar on all multi-page forms to start at zero percent.
add_filter('gform_progressbar_start_at_zero', '__return_true');
Set progress bar to start at zero for a specific form
This example sets the progress bar to start at zero percent for a specific form with the ID 2.
function my_gform_progressbar_start_at_zero($start_at_zero, $form_id) {
if ($form_id == 2) {
return true;
}
return $start_at_zero;
}
add_filter('gform_progressbar_start_at_zero', 'my_gform_progressbar_start_at_zero', 10, 2);
Set progress bar to start at zero for multiple forms
This example sets the progress bar to start at zero percent for forms with the IDs 1, 3, and 5.
function my_gform_progressbar_start_at_zero($start_at_zero, $form_id) {
$target_form_ids = array(1, 3, 5);
if (in_array($form_id, $target_form_ids)) {
return true;
}
return $start_at_zero;
}
add_filter('gform_progressbar_start_at_zero', 'my_gform_progressbar_start_at_zero', 10, 2);
Set progress bar to start at zero based on user role
This example sets the progress bar to start at zero percent for users with the ‘editor’ role.
function my_gform_progressbar_start_at_zero($start_at_zero) {
if (current_user_can('editor')) {
return true;
}
return $start_at_zero;
}
add_filter('gform_progressbar_start_at_zero', 'my_gform_progressbar_start_at_zero');
Set progress bar to start at zero based on a condition
This example sets the progress bar to start at zero percent if a global variable $start_progress_at_zero is true.
global $start_progress_at_zero;
$start_progress_at_zero = true;
function my_gform_progressbar_start_at_zero($start_at_zero) {
global $start_progress_at_zero;
if ($start_progress_at_zero) {
return true;
}
return $start_at_zero;
}
add_filter('gform_progressbar_start_at_zero', 'my_gform_progressbar_start_at_zero');