Using Gravity Forms ‘gform_disable_view_counter’ PHP filter

The gform_disable_view_counter filter allows you to prevent the form view counter from being incremented in Gravity Forms.

Usage

Use this filter to apply it to all forms:

add_filter('gform_disable_view_counter', 'your_function_name');

To limit the scope of your function to a specific form, append the form ID to the end of the hook name (format: gform_disable_view_counter_FORMID):

add_filter('gform_disable_view_counter_5', 'your_function_name');

Parameters

  • $view_counter_disabled (bool): Indicates if the view counter is disabled. Default is false.

More information

See Gravity Forms Docs: gform_disable_view_counter

Examples

Disable view counter for all forms

Disable the view counter for all forms by returning true:

add_filter('gform_disable_view_counter', '__return_true');

Enable view counter for a specific form

Enable the view counter for a specific form (form ID 12) by returning false:

add_filter('gform_disable_view_counter_12', '__return_false');

Disable view counter for a specific IP

Disable the view counter for a specific IP address (replace ‘SOMEIP’ with the actual IP address):

add_filter('gform_disable_view_counter', 'disable_view_count_by_ip');
function disable_view_count_by_ip($view_counter_disabled) {
   if (GFFormsModel::get_ip() == 'SOMEIP') {
        return true;
   }
   return $view_counter_disabled;
}

Placement

This code should be placed in the functions.php file of your active theme.