GF_LOGGING_DISABLE_NOTICE

GF_LOGGING_DISABLE_NOTICE

DescriptionUsagePlacement

Description
Allows the non-dismissible security notice which displays on every WordPress admin page when logging is enabled to be turned off.
Usage
define( 'GF_LOGGING_DISABLE_NOTICE', true );

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

GF_Field_Website

GF_Field_Website

IntroductionSettings and PropertiesSettingsPropertiesSource Code

Introduction
The GF_Field_Website class extends the GF_Field class, also known as the Field Object. This class is responsible for determining how the website 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.

default_value_setting
Controls whether the 「Default Values」 section displays. This allows a value to be set for the field.

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

duplicate_setting
Controls whether the 「No Duplicates」 setting displays within the 「Rules」 section. This controls whether the same value may exist more than once in the database. The 「Rules」 setting must be active for this to display.

error_message_setting
Controls whether the 「Custom Validation Message」 setting which allows a custom message to be used appears.

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

placeholder_setting
Controls whether the 「Placeholders」 section appears. This allows placeholder text to display for the field.

prepopulate_field_setting
Controls whether the 「Allow field to be populated dynamically」 setting appears.

rules_setting
Controls whether the 「Rules」 settings section displays. The 「Required」 option shows when this is active.

size_setting
Controls whether the 「Field Size」 setting displays. This controls the size of the input field for fields to which it applies. The sizes are 「small」, 「medium」, and 「large」.

visibility_setting
Controls whether the 「Visibility」 setting displays. The controls whether the option of visibility being for 「Everyone」 or 「Admin Only」 can be set.

Properties
Below is a listing of the properties inherited from the parent class. There are no properties unique to the Website field.

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

adminOnly boolean
Determines whether the field is visible to the user submitting the form, or only visible in the admin.

allowsPrepopulate boolean
Determines if the field values can be dynamically populated. Default is false.

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.

defaultValue string
The default value to be displayed in the input 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.

errorMessage string
The custom error message to be displayed if the field fails validation.

formId integer
The form ID.

id integer
The field ID.

isRequired boolean
Marking the field as required will prevent the form from being submitted if the user does not enter a value. Default is false.

label string
The field label that will be displayed on the form and on the admin pages.

maxLength string
The number of characters that the field is allowed to contain.

noDuplicates boolean
Determines if the value entered by the user may already exist in the database.

placeholder string
Placeholder text to give the user a hint on how to fill out the field. This is not submitted with the form. For the website field, the text 「http://」 is displayed.

size string
Controls the width of the input field. The choices are 「small」, 「medium」, and 「large」.

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

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

GF_User_Registration

GF_User_Registration

Introductiongf_user_registration()maybe_process_feed()get_single_submission_feed()get_meta_value()add_validation_error()get_user_by_entry_id()get_site_by_entry_id()insert_feed()add_note()log_debug()log_error()

Introduction
GF_User_Registration is the class which houses the main functionality of the Gravity Forms User Registration Add-on; it extends the GFFeedAddOn class which is part of the add-on framework. Below are a few functions which you may find useful when working on your own custom code.
gf_user_registration()
The gf_user_registration() function is used to return an instance of the GF_User_Registration class.
maybe_process_feed()
Triggers processing of the User Registration feeds for the specified form and entry objects.
$entry = gf_user_registration()->maybe_process_feed( $entry, $form );

$entry Entry Object
The Entry Object to be processed.

$form Form Object
The Form Object to be processed.

Returns Entry Object

get_single_submission_feed()
Retrieves the feed for the specified form and entry objects.
$feed = gf_user_registration()->get_single_submission_feed( $entry, $form );

$entry Entry Object
The Entry Object to be processed.

$form Form Object
The Form Object to be processed.

Returns Feed Object|boolean
The feed which was used to process the supplied entry object or false if a feed wasn』t processed for the entry and an active feed with matching conditional logic could not be found.

get_meta_value()
Retrieves the value to be used for the specified meta key.
$value = gf_user_registration()->get_meta_value( $meta_key, $meta, $form, $entry );

$meta_key string
The meta key for the field which was mapped when configuring the feed.

$meta User Registration Feed Meta
The array containing the feed properties.

$form Form Object
The Form Object being processed.

$entry Entry Object
The Entry Object being processed.

Returns string
The value matching the meta mapping for the given meta key or if not found, an empty string.

add_validation_error()
Useful when performing custom validation using the gform_user_registration_validation filter to add a custom validation error message.
$form = gf_user_registration()->add_validation_error( $field_id, $form, $message );

$field_id integer
The ID of the field the validation error should be applied to.

$form Form Object
The Form Object to be processed.

$message string
The validation message to be applied to the field.

Returns Form Object

get_user_by_entry_id()
Retrieve the user object or id for the user which was created or updated by the supplied entry id.
$user = gf_user_registration()->get_user_by_entry_id( $entry_id );
$user_id = gf_user_registration()->get_user_by_entry_id( $entry_id, true );

$entry_id integer
The ID of the entry the user was created or updated from.

$id_only boolean
Defaults to false. Indicates if the user ID should be returned instead of the full WP_User object

Returns boolean|integer|WP_User
False if a user wasn』t created or updated from the entry, or the user id or WP_User object.

get_site_by_entry_id()
Retrieve the id of the site which was created or updated by the supplied entry id.
$site = gf_user_registration()->get_site_by_entry_id( $entry_id );

$entry_id integer
The ID of the entry the user was created or updated from.

Returns boolean|integer
False if a site wasn』t created or updated from the entry, or the site id.

insert_feed()
The insert_feed() method can be used to add User Registration feeds.
$feed_id = gf_user_registration()->insert_feed( $form_id, $is_active, $meta );

$form_id integer
The ID of the form this feed will be used with.

$is_active boolean
Is this feed active or inactive.

$meta User Registration Feed Meta
An associative array containing the properties which determine if a user will be updated or created when the feed is processed.

Returns integer
The ID of the new feed.

add_note()
Add a note to the specified Entry.
gf_user_registration()->add_note( $entry_id, $note, $note_type );

$entry_id integer
The ID of the Entry this note should be added to.

$note string
The note to be added.

$note_type string
The type of note to be added. Example values: note, success, or error.

log_debug()
Writes a debug message to the log file for the User Registration Add-On. Requires the Logging Add-On.
gf_user_registration()->log_debug( $message );

$message string
The message to be written to the User Registration log.

log_error()
Writes an error message to the log file for the User Registration Add-On. Requires the Logging Add-On.
gf_user_registration()->log_error( $message );

$message string
The message to be written to the User Registration log.

GF_Field

GF_Field

IntroductionGetting StartedMain Functionalityget_form_editor_field_title()get_form_editor_button()get_form_editor_field_settings()is_conditional_logic_supported()get_field_input()get_field_content()validate()get_form_inline_script_on_page_render()get_form_editor_inline_script_on_page_render()get_value_save_entry()get_value_merge_tag()get_value_entry_detail()SanitizationInput SanitizationOutput SanitizationHelpersget_input_type()get_tabindex()get_conditional_logic_event()get_field_placeholder_attribute()get_input_placeholder_attribute()Core Field ClassesAdd-On Field Classes

Introduction

The GF_Field class provides basic functionality for developers when creating new fields for Gravity Forms. It facilitates the following:

Adding a button for the field to the form editorDefining the field title to be used in the form editorDefining which settings should be present when editing the fieldRegistering the field as compatible with conditional logicOutputting field scripts to the form editor and front-endDefining the field appearance on the front-end, in the form editor and on the entry detail pageValidating the field during submissionSaving the entry valueDefining how the entry value is displayed when merge tags are processed, on the entries list and entry detail pagesDefining how the entry value should be formatted when used in csv exports and by framework based add-ons

Getting Started

These are the first steps you』ll need to take to create a field using the Field Framework.

Creating a new class which extends GF_Field (Note: If your new field will have similar functionality to an existing field you can save some work by extending that field type instead e.g. GF_Field_Post_Image extends GF_Field_Fileupload)Add the $type variableRegister the field with Gravity Forms

Example:

123456class GF_Field_Phone extends GF_Field {     public $type = 'phone'; }GF_Fields::register( new GF_Field_Phone() );

Main Functionality

Now you have the basic field you can start defining its appearance and behaviour by overriding functions from GF_Field or whichever the class you extended.

The examples shown below are taken from various field types.

get_form_editor_field_title()

The default behaviour of get_form_editor_field_title() is to return the value of the $type variable, however, you may want the field in the form editor to use a different title or have the first letter uppercased in which case you will want to override this method.

public function get_form_editor_field_title() {}

Example:

public function get_form_editor_field_title() {    return esc_attr__( 'Phone', 'gravityforms' );}

get_form_editor_button()

The default behaviour of get_form_editor_button() is to return an associative array assigning the field to the standard_fields group using the value returned by get_form_editor_field_title() as the button text.

The built-in groups are standard_fields, advanced_fields, post_fields, and pricing_fields. See the How To Add A Custom Field Group When Using The Field Framework article for an example showing how you can define a new group.

public function get_form_editor_button() {}

Example:

public function get_form_editor_button() {    return array(        'group' => 'advanced_fields',        'text'  => $this->get_form_editor_field_title()    );}

get_form_editor_field_settings()

The default behaviour of get_form_editor_field_settings() is to return an empty array so you will want to override this method and return an array containing the class names of the settings you want to appear on your field in the form editor.

You can find a list of the available settings in the following articles:

General Field SettingsAppearance Field SettingsAdvanced Field Settings

You can also define your own custom settings by using the gform_field_standard_settings, gform_field_appearance_settings, and gform_field_advanced_settings hooks.

function get_form_editor_field_settings() {}

Example:

function get_form_editor_field_settings() {    return array(        'conditional_logic_field_setting',        'prepopulate_field_setting',        'error_message_setting',        'label_setting',        'label_placement_setting',        'admin_label_setting',        'size_setting',        'rules_setting',        'visibility_setting',        'duplicate_setting',        'default_value_setting',        'placeholder_setting',        'description_setting',        'phone_format_setting',        'css_class_setting',    );}

is_conditional_logic_supported()

The default behaviour of is_conditional_logic_supported() is to return false meaning the field can』t be used with conditional logic. Override this method returning true to allow the field to be used when configuring conditional logic rules.

public function is_conditional_logic_supported() {}

Example:

public function is_conditional_logic_supported() {    return true;}

get_field_input()

This method is used to define the fields inner markup, including the div with the ginput_container class. The default behaviour of get_field_input() is to return an empty string so you will want to override this method.

public function get_field_input( $form, $value = '', $entry = null ) {}

Parameters:

$form Form ObjectThe form object currently being processed.$value string|arrayThe field value from the $_POST or the resumed incomplete submission.$entry null|Entry ObjectNull or the entry object currently being edited.

Return:

The field』s inner markup. string

Example:

public function get_field_input( $form, $value = '', $entry = null ) {    $form_id         = $form['id'];    $is_entry_detail = $this->is_entry_detail();    $id              = (int) $this->id;     if ( $is_entry_detail ) {        $input = "";         return $input . '
' . esc_html__( 'Coupon fields are not editable', 'gravityformscoupons' );    }     $disabled_text         = $this->is_form_editor() ? 'disabled="disabled"' : '';    $logic_event           = version_compare( GFForms::$version, '2.4.1', '<' ) ? $this->get_conditional_logic_event( 'change' ) : '';    $placeholder_attribute = $this->get_field_placeholder_attribute();    $coupons_detail        = rgpost( "gf_coupons_{$form_id}" );    $coupon_codes          = empty( $coupons_detail ) ? '' : rgpost( "input_{$id}" );     $input = "

" .             "get_tabindex() . '/>' .             "get_tabindex() . '/> ' .             "" .             "

" .             "" .             "" .             "" .             "

";     return $input;}

get_field_content()

This method is used to define the fields overall appearance, such as how the admin buttons, field label, description or validation messages are included. Most fields won』t need to override this method, display only types such as Page, Section or HTML are examples of fields which do override the get_field_content() method.

1public function get_field_content( $value, $force_frontend_label, $form ) {}

Parameters:

$value string|array
The field value from the $_POST or the resumed incomplete submission.

$force_frontend_label boolean
Should the frontend label be displayed in the admin even if an admin label is configured. Default is false.

$form Form Object
The form object currently being processed.

Return:
The fields markup. string. Note: use the placeholder {FIELD} to define where the markup returned by get_field_input() should be included.

Example:

public function get_field_content( $value, $force_frontend_label, $form ) {    $form_id         = $form['id'];    $admin_buttons   = $this->get_admin_buttons();    $is_entry_detail = $this->is_entry_detail();    $is_form_editor  = $this->is_form_editor();    $is_admin        = $is_entry_detail || $is_form_editor;    $field_label     = $this->get_field_label( $force_frontend_label, $value );    $field_id        = $is_admin || $form_id == 0 ? "input_{$this->id}" : 'input_' . $form_id . "_{$this->id}";    $field_content   = ! $is_admin ? '{FIELD}' : $field_content = sprintf( "%s{FIELD}", $admin_buttons, $field_id, esc_html( $field_label ) );     return $field_content;}

validate()

Override this method to perform custom validation logic. This method is only used if the field passes the required validation (field is not empty), and any no duplicates validation.

1public function validate( $value, $form ) {}

Parameters:

$value string|array
The field value from the $_POST.

$form Form Object
The form object currently being processed.

Return:
This method does not return a value via a return statement. Return the validation result and message by setting the fields failed_validation and validation_message properties.

Example:

public function validate( $value, $form ) {    $regex = '/^D?(d{3})D?D?(d{3})D?(d{4})$/';    if ( $this->phoneFormat == 'standard' && $value !== '' && $value !== 0 && ! preg_match( $regex, $value ) ) {        $this->failed_validation = true;        if ( ! empty( $this->errorMessage ) ) {            $this->validation_message = $this->errorMessage;        }    }}

get_form_inline_script_on_page_render()

Override this method to include scripts with the form init scripts on page render. The init scripts are usually included immediately after the form in the page body.

Note: