gf_has_filters

gf_has_filters

DescriptionUsageParametersReturnsExamplesSinceSource Code

Description
Determines if a callback has been registered for the specified filter.
Usage
1gf_has_filters( array( 'filter_name', $modifier1 ) );
This helper function also has an alias, gf_has_filter, which can be used like so:
1gf_has_filter( array( 'filter_name', $modifier1 ) );

Parameters

$filter array
Array containing the filter tag as well as the possible modifiers.

$function_to_check bool|callable
The optional callback to check for.

Returns
Returns boolean for whether the hook has any callbacks registered or if a specific callback is registered.

Examples
1$result = gf_has_filters( array( 'gform_pre_render', $form_id ) );
1$result = gf_has_filter( array( 'gform_pre_render', $form_id ) );
1$result = gf_has_filters( array( 'gform_disable_view_counter', $form_id ), '__return_true' );
Since
The gf_has_filters and gf_has_filter functions were added in Gravity Forms version 2.4.18.
Source Code
These helper functions are located in gravityforms.php

GFFeedAddOn

GFFeedAddOn

IntroductionCreating Feed SettingsFeed Settings Fields ExampleDynamic Feed MappingAdding Columns to Feed ListAdding Columns to Feed List ExampleProcessing FeedsImplementing a Feed Condition SettingFeed Condition Field ExamplesAsynchronous Feed ProcessingGFFeedAddOn $_async_feed_processing Propertygform_is_feed_asynchronous FilterFurther ReadingSample Feed Add-On

Introduction

The GFFeedAddOn class provides basic functionality for developers when creating new feed-based add-ons for Gravity Forms. It includes all the features of the GFAddOn class with one exception; the Form Settings are replaced by the Feed Settings UI.

Before reading any further please review the documentation for creating a simple add-on using the GFAddOn class.

Settings APICreating Plugin SettingsIncluding Scripts And Styles When Using The Add-On FrameworkIncluding And Using Entry Meta With The Add-On FrameworkObject LockingCreating a Results PageUninstalling

Creating Feed Settings

The feed settings UI is generated by overriding the feed_settings_fields() function and returning an array with the configuration for each of the fields. The configuration array follows the same structure as the form settings configuration. See the Settings API for further details on the structure of the array.

Feed Settings Fields Example

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142public function feed_settings_fields() {    return array(        array(            'title'  => 'Simple Form Settings',            'fields' => array(                array(                    'label'   => 'My checkbox',                    'type'    => 'checkbox',                    'name'    => 'enabled',                    'tooltip' => 'This is the tooltip',                    'choices' => array(                        array(                            'label' => 'Enabled',                            'name'  => 'enabled'                        )                     )                ),                array(                    'label'   => 'My checkboxes',                    'type'    => 'checkbox',                    'name'    => 'checkboxgroup',                    'tooltip' => 'This is the tooltip',                    'choices' => array(                        array(                            'label' => 'First Choice',                            'name'  => 'first'                        ),                        array(                            'label' => 'Second Choice',                            'name'  => 'second'                        ),                        array(                            'label' => 'Third Choice',                            'name'  => 'third'                        )                    )                ),                array(                    'label'   => 'My Radio Buttons',                    'type'    => 'radio',                    'name'    => 'myradiogroup',                    'tooltip' => 'This is the tooltip',                    'choices' => array(                        array(                            'label' => 'First Choice'                        ),                        array(                            'label' => 'Second Choice'                        ),                        array(                            'label' => 'Third Choice'                        )                    )                ),                array(                    'label'      => 'My Horizontal Radio Buttons',                    'type'       => 'radio',                    'horizontal' => true,                    'name'       => 'myradiogrouph',                    'tooltip'    => 'This is the tooltip',                    'choices'    => array(                        array(                            'label' => 'First Choice'                        ),                        array(                            'label' => 'Second Choice'                        ),                        array(                            'label' => 'Third Choice'                        )                    )                ),                array(                    'label'   => 'My Dropdown',                    'type'    => 'select',                    'name'    => 'mydropdown',                    'tooltip' => 'This is the tooltip',                    'choices' => array(                        array(                            'label' => 'First Choice',                            'value' => 'first'                        ),                        array(                            'label' => 'Second Choice',                            'value' => 'second'                        ),                        array(                            'label' => 'Third Choice',                            'value' => 'third'                        )                    )                ),                array(                    'label'             => 'My Text Box',                    'type'              => 'text',                    'name'              => 'mytext',                    'tooltip'           => 'This is the tooltip',                    'class'             => 'medium',                    'feedback_callback' => array( $this, 'is_valid_setting' )                ),                array(                    'label'   => 'My Text Area',                    'type'    => 'textarea',                    'name'    => 'mytextarea',                    'tooltip' => 'This is the tooltip',                    'class'   => 'medium merge-tag-support mt-position-right'                ),                array(                    'label'   => 'My Hidden Field',                    'type'    => 'hidden',                    'name'    => 'myhidden'                ),                array(                    'label'   => 'My Custom Field',                    'type'    => 'my_custom_field_type',                    'name'    => 'my_custom_field'                ),                array(                    'type'           => 'feed_condition',                    'name'           => 'mycondition',                    'label'          => __( 'Opt-In Condition', 'simplefeedaddon' ),                    'checkbox_label' => __( 'Enable Condition', 'simplefeedaddon' ),                    'instructions'   => __( 'Process this example feed if', 'simplefeedaddon' )                ),            )        ),        array(            'title'  => esc_html__( 'This is the title for Section 1', 'sometextdomain' ),            'fields' => array(                array(                    'name'                => 'metaData',                    'label'               => esc_html__( 'Metadata', 'sometextdomain' ),                    'type'                => 'dynamic_field_map',                    'limit'               => 20,                    'exclude_field_types' => 'creditcard',                    'tooltip'             => '

' . esc_html__( 'Metadata', 'sometextdomain' ) . '

' . esc_html__( 'You may send custom meta information to [...]. A maximum of 20 custom keys may be sent. The key name must be 40 characters or less, and the mapped data will be truncated to 500 characters per requirements by [...]. ', 'sometextdomain' ),                    'validation_callback' => array( $this, 'validate_custom_meta' ),                ),            ),        ),    );}

The code above will render a Form Settings page for the Simple Add-On similar to this:

Dynamic Feed Mapping

Dynamic feed mapping can be used to create fields which automatically map to values in the form. For example, if you need to create a feed that uses information such as a first name and last name, field mapping would be used to map the form fields to those values.

A dynamically mapped field can be implemented just like many of the other feed settings fields and setting the setting field type to dynamic_field_map. Adding a feed section containing dynamically mapped fields would look something like the following:

1234567891011121314array(    'title'  => esc_html__( 'This is the title for Section 1', 'sometextdomain' ),    'fields' => array(        array(            'name'                => 'metaData',            'label'               => esc_html__( 'Metadata', 'sometextdomain' ),            'type'                => 'dynamic_field_map',            'limit'               => 20,            'exclude_field_types' => 'creditcard',            'tooltip'             => '

' . esc_html__( 'Metadata', 'sometextdomain' ) . '

' . esc_html__( 'You may send custom meta information to [...]. A maximum of 20 custom keys may be sent. The key name must be 40 characters or less, and the mapped data will be truncated to 500 characters per requirements by [...]. ', 'sometextdomain' ),            'validation_callback' => array( $this, 'validate_custom_meta' ),        ),    ),)

More information on the dynamic_field_map field type can be found on the dynamic_field_map Field documentation.

Adding Columns to Feed List

To add columns to the list of feeds, override the feed_list_columns() function and return an array of column keys with their corresponding titles. The values will be rendered to the list automatically, but if you need to customize the value just before it is rendered to the list, declare a function with the name get_column_value_[column key] and pass the $feed object as a parameter to the function. The feed object is an associative array with the keys as defined in feed_settings_fields() with the corresponding values for the current row.

Adding Columns to Feed List Example

This example adds two columns to the feed list. The columns are titled 「Name」 and 「My Textbox」. The get_column_value_mytext function returns the value for the 「mytext」 field as bold text.

1234567891011protected function feed_list_columns() {    return array(        'feedName' => __( 'Name', 'simplefeedaddon' ),        'mytext'   => __( 'My Textbox', 'simplefeedaddon' )    );} // customize the value of mytext before it is rendered to the listpublic function get_column_value_mytext( $feed ){    return '' . rgars( $feed, 'meta/mytext' ) . '';}

The code above will render a Feed List page similar to the following:

Processing Feeds

Override the process_feed() method to add code to handle feed processing, such as passing the form entry values to a third-party service.

1public function process_feed( $feed, $entry, $form ) {}

We recommend using get_field_value() to retrieve the entry value for a mapped field e.g.

1$email = $this->get_field_value( $form, $entry, $feed['meta']['listFields_email'] );

Implementing a Feed Condition Setting

A feed condition setting is a feed setting that automatically adds an optional conditional logic setting to the feed. The field is configured just like the other fields (see the Settings API) with the the following properties:

type string『feed condition』name stringThe name for the setting.label stringThe label for the feed condition setting.checkbox_label stringThe label that appears to the right of the checkbox used to enable the condition. If this is not set, the default translated string 「Enable Condition」 is used.instructions stringThe instruction text appears above the conditional logic drop downs, is followed by the All/Any drop down selection, and the translated text 「of the following match」. If you do not specify instruction text, the text 「Process this feed if」 is used.

Feed Condition Field Examples

This is a simple example that uses the basic settings to create the feed condition field.

12345array(    'type'  => 'feed_condition',    'name'  => 'sample_condition',    'label' => 'Feed Condition',)

The code above will render the feed condition field as follows:

This example includes setting the checkbox_label and instructions.

1234567array(    'type'           => 'feed_condition',    'name'           => 'mycondition',    'label'          => __( 'Opt-In Condition', 'simplefeedaddon' ),    'checkbox_label' => __( 'Enable Condition', 'simplefeedaddon' ),    'instructions'   => __( 'Process this example feed if', 'simplefeedaddon' ))

The code above will render the feed condition field as follows:

Asynchronous Feed Processing

As of Gravity Forms version 2.2, feeds can be loaded asynchronously. This means that instead of processing all of the feeds at once, the feeds will be loaded individually.

GFFeedAddOn $_async_feed_processing Property

To load a feed asynchronously, set the $_async_feed_processing property within the GFFeedAddOn class to true.

Example:

123class My_Feed_AddOn extends GFFeedAddOn {    public $_async_feed_processing = true;}

gform_is_feed_asynchronous Filter

Example:

1add_filter( 'gform_is_feed_asynchronous'. '__return_true' );

See gform_is_feed_asynchronous

Further Reading

The following articles may also be useful:

Sending Notifications on Custom Events when using the Add-On FrameworkAdding a Note to the Entry when using the Add-On FrameworkAccessing Mapped Field Values During Feed Processing

Sample Feed Add-On

A sample feed add-on is available which demonstrates the basic functions of GFFeedAddOn:

Feed settings including feed conditionsPlugin pagePlugin SettingsScripts and Styles

https://github.com/rocketgenius/simplefeedaddon

GF_RECAPTCHA_PUBLIC_KEY

GF_RECAPTCHA_PUBLIC_KEY

DescriptionUsagePlacement

Description
Automatically pre-populates the reCAPTCHA public key when a new site is created on your Multi-Site install.
Usage
define( 'GF_RECAPTCHA_PUBLIC_KEY', 'YOUR-KEY-HERE' );

Placement
This constant should be set in your wp-config.php. See the article Wp Config Options for more details.

GF_IMPORT_FILE

GF_IMPORT_FILE

DescriptionUsagePlacement

Description
Setting this option allows you to specify a Form JSON file from which a set of default forms can be pre-generated when a new site is created on your Multi-Site install.
Usage
1define( 'GF_IMPORT_FILE', 'http://www.domain.com/path/to/gf_import.json' );
Placement
This constant should be set in your wp-config.php. See the article Wp Config Options for more details regarding the JSON file.

gform_action_pre_payment_callback

gform_action_pre_payment_callback

DescriptionUsageParametersExamplesSource Code

Description
Runs a function after payment, before the callback occurs.
Usage
1add_action( 'gform_action_pre_payment_callback', 'my_function', 10, 2 );

Parameters

$action array
Array for the payment action triggered.

$entry Entry Object
Entry object for the new entry.

Examples
123456function my_function($action, $entry) {    if( $action['type'] == 'complete_payment' ) {        // Do something    }}add_action( 'gform_action_pre_payment_callback', 'my_function', 10, 2 );
Source Code
1do_action( 'gform_action_pre_payment_callback', $action, $entry );
This action hook is located in GFPaymentAddOn::process_callback_action() in includes/addon/class-gf-payment-addon.php.

GF_LICENSE_KEY

GF_LICENSE_KEY

DescriptionUsagePlacement

Description
Setting this option before installing Gravity Forms on a single site WP installation or before creating new sites on a multisite install will automatically pre-populate your Gravity Forms license key for those new installations.
Usage
define( 'GF_LICENSE_KEY', 'YOUR-LICENSE-KEY-HERE' );

Placement
This constant should be set in your wp-config.php. See the article Wp Config Options.

gform_activate_user

gform_activate_user

DescriptionUsageParametersExamplePlacementSource Code

Description
The 「gform_activate_user」 action fires after a user signup has been activated. This action is used in the User Registration plugin for Gravity Forms.
Usage
1add_action( 'gform_activate_user', 'your_function_name, 10, 3 );

Parameters

$user_id int
The user id of the signup user just activated.

$user_data array
An array of the user information.

$signup_meta array
All the metadata in an array (user login, email, password, etc.)

Example
12345add_action( 'gform_activate_user', 'after_user_activate', 10, 3 );function after_user_activate( $user_id, $user_data, $signup_meta ) {    //add note to entry    GFFormsModel::add_note( $signup_meta['lead_id'], $user_id, 'admin', 'The user signup has completed for ' . $user_data['display_name'] . '.');}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This action is located in GF_User_Registration::activate_signup() in gravityformsuserregistration/includes/signups.php.

GF_Field_Total

GF_Field_Total

IntroductionSettings and PropertiesSettingsPropertiesSource Code

Introduction
The GF_Field_Total class extends the GF_Field class, also known as the Field Object. This class is responsible for determining how the Total field is rendered when the form is displayed and how its value is handled during and after form submission.
Settings and Properties
Settings control what options are available to the admin user when configuring the field in the form editor. Gravity Forms includes many built-in settings such as Field Label, Field Description, Choices, Conditional Logic, etc. In addition to built-in settings, custom settings can also be developed. For more information on how to develop custom settings and how to associate settings to a field, visit the GF_Field page.
Properties contain the values specified by the settings and generally are part of the Field Object.
The properties may be retrieved by accessing the Field Object as follows:
12345//get the field$field = GFFormsModel::get_field( $form, 1 ); //get the admin label$admin_label = $field->adminLabel;
Settings
The following settings are available for the field:

admin_label_setting
Controls whether the 「Admin Field Label」 setting appears.

conditional_logic_field_setting
Controls whether the 「Enable Conditional Logic」 setting appears.

css_class_setting
Controls whether the 「Custom CSS Class」 setting displays. This allows a custom css to be used for the field.

description_setting
Controls whether the 「Description」 setting appears. This allows a description for the field to be displayed.

label_setting
Controls whether the 「Field Label」 setting which allows the label to be changed appears.

Properties
Below is a listing of the properties inherited from the parent class and ones specific to the field.

adminLabel string
The label to be used on admin pages instead of the label, useful for fields with long labels.

conditionalLogic array
An associative array containing the conditional logic rules. See the Conditional Logic Object for more details.

cssClass string
The custom CSS class or classes to be added to the input tag for the field.

description string
The field description.

descriptionPlacement string
The placement of the field description. The description may be placed 「above」 or 「below」 the field inputs. If the placement is not specified, then the description placement setting for the Form Layout is used.

formId integer
The form ID.

id integer
The field ID.

type string
The field type, which in this case is total.

Source Code
The source code is located in includes/fields/class-gf-field-total.php in the Gravity Forms folder of your sites plugins directory.

GF_THEME_IMPORT_FILE

GF_THEME_IMPORT_FILE

DescriptionUsagePlacement

Description
Setting this option allows you to specify a Form JSON file from which a set of default forms can be pre-generated when a theme containing this option is activated. This option can also be used in your theme』s functions.php file.
Usage
define( 'GF_THEME_IMPORT_FILE', 'path/to/gf_import.json' );

Note: The path is relative to your theme root.
Placement
This constant should be set in your wp-config.php. See the article Wp Config Options for more details regarding the JSON file.