Using Gravity Forms ‘gform_include_thousands_sep_pre_format_number’ PHP filter

The gform_include_thousands_sep_pre_format_number filter in Gravity Forms PHP allows you to prevent the thousand separator from being included when the number field value is formatted for display in the admin, notifications, and confirmations.

Usage

add_filter('gform_include_thousands_sep_pre_format_number', 'your_function_name', 10, 2);

Parameters

  • $include_separator (boolean): Should the thousand separator be included. Default is true.
  • $field (Field Object): The field that is currently being processed.

More information

See Gravity Forms Docs: gform_include_thousands_sep_pre_format_number

Examples

Disable thousand separator for all number fields on all forms

This example disables the thousand separator for all number fields on all forms.

add_filter('gform_include_thousands_sep_pre_format_number', '__return_false');

Disable thousand separator for a specific field

This example disables the thousand separator for a specific field with form ID 20 and field ID 45.

add_filter('gform_include_thousands_sep_pre_format_number', function ($include_separator, $field) {
    return $field->formId == 20 && $field->id == 45 ? false : $include_separator;
}, 10, 2);

Disable thousand separator for a specific form

This example disables the thousand separator for all number fields in a form with form ID 10.

add_filter('gform_include_thousands_sep_pre_format_number', function ($include_separator, $field) {
    return $field->formId == 10 ? false : $include_separator;
}, 10, 2);

Enable thousand separator only for fields with a specific label

This example enables the thousand separator only for number fields with the label “Price”.

add_filter('gform_include_thousands_sep_pre_format_number', function ($include_separator, $field) {
    return $field->label == 'Price' ? true : $include_separator;
}, 10, 2);

Disable thousand separator based on a custom condition

This example disables the thousand separator for number fields with form ID 5 and field ID 12, but only if the field’s value is greater than 1000.

add_filter('gform_include_thousands_sep_pre_format_number', function ($include_separator, $field) {
    if ($field->formId == 5 && $field->id == 12 && $field->value > 1000) {
        return false;
    }
    return $include_separator;
}, 10, 2);

Note: Place the code examples in the functions.php file of your active theme.