gform_disable_view_counter

Description

This filter can be used to prevent the forms view counter being incremented. The views column will remain displayed on the Forms page.

Usage

The following would apply 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

    Is the view counter disabled. Default false.

Examples

1. Disable for all forms

add_filter( 'gform_disable_view_counter', '__return_true' );

2. Enable for a specific form

add_filter( 'gform_disable_view_counter_12', '__return_false' );

3. Disable for a specific ip

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.

Source Code

This filter is located in GFFormDisplay::get_form() in form_display.php

Since

This filter was added in Gravity Forms 1.8.17.