Skip to main content

GFFormsModel

Class GFFormsModel

Handles database calls and formatting of stored data regarding forms

Source: forms_model.php:18

Details​

  • Kind: class
  • Namespace: (global)

Properties​

PropertyTypeDescription
$uploaded_filesarrayDefaults to an empty array.
$unique_idsarrayDefaults to an empty array.

Methods​

MethodDescription
get_database_version()Returns the current database version.
flush_current_forms()Flushes the data stored within GFFormsModel::$_current_forms.
flush_current_lead()Flushes the data stored within GFFormsModel::$_current_lead.
flush_current_form()Removes the cached properties, meta, and confirmations for a specific form.
flush_confirmations()Flushes the data stored within GFFormsModel::$_confirmations
get_form_table_name()Gets the form table name, including the site's database prefix.
get_meta_table_name()Gets the form meta table, including the site's database prefix.
get_form_view_table_name()Gets the form view table name, including the site's database prefix.
get_form_revisions_table_name()Gets the form revisions table name, including the site's database prefix.
get_lead_table_name()Gets the lead (entries) table name, including the site's database prefix.
get_lead_meta_table_name()Gets the lead (entry) meta table name, including the site's database prefix.
get_lead_notes_table_name()Gets the lead (entry) notes table name, including the site's database prefix.
get_lead_details_table_name()Gets the lead (entry) details table name, including the site's database prefix.
get_lead_details_long_table_name()Gets the lead (entry) details long table name, including the site's database prefix.
get_lead_view_name()Gets the lead (entry) view table name, including the site's database prefix.
get_incomplete_submissions_table_name()Gets the incomplete submissions table name, including the site's database prefix.
get_entry_table_name()Gets the entry table name, including the site's database prefix
get_entry_meta_table_name()Gets the entry meta table name, including the site's database prefix
get_entry_notes_table_name()Gets the lead (entry) notes table name, including the site's database prefix
get_draft_submissions_table_name()Gets the draft submissions table name, including the site's database prefix
get_rest_api_keys_table_name()Gets the REST API Key table name, including the site's database prefix
get_addon_feed_table_name()Returns the name of the table where add-on feeds are stored, including the site's database prefix.
get_forms()Gets all forms.
search_forms()Searches form titles based on query.
get_entry_count_per_form()Gets the number of entries per form.
get_view_count_per_form()Gets the number of views per form
get_form_db_columns()Returns the form database columns.
get_form_payment_totals()Gets the payment totals for a particular form ID.
get_form_counts()Gets the total, unread, starred, spam, and trashed entry counts.
get_form_summary()Gets the form summary for all forms.
get_form_count()Gets the total, active, inactive, and trashed form counts.
get_form_id()Gets the form ID based on the form title.
get_form_cache_key()Returns the cache key for the specified form.
get_form()Returns an object containing the properties of the specified form or false if the form doesn't exist.
unserialize()Converts a serialized string or JSON for access in PHP.
get_form_meta()Gets the form meta based on the form ID.
has_legacy_markup()Query request checking if the site contains any forms with Legacy markup.
get_next_field_id()Recursively checks the highest ID for all the fields in the form and then returns the highest ID + 1.
convert_field_objects()Converts all field objects in a form, based on field type.
get_form_meta_by_id()Gets the form meta for multiple forms based on an array for form IDs.
get_grid_column_meta()Gets the column info for the entry listing page.
update_form_active()Updates the form is_active property in the database.
change_entries_status()Changes the status of multiple entries.
change_entry_status()Changes the status of a single entry.
restore_entry_status()Restores the status of a single entry to its previous status.
restore_entries_status()Restores the status of multiple entries to their previous status.
delete_leads()
delete_views()Delete the views for the specified form.
duplicate_form()Duplicate form.
maybe_increment_title()If a form title isn't unique, add a number to it to make it unique.
update_form_meta()Update form meta.
maybe_create_form_revision()Create form revision if conditions met.
get_latest_form_revisions_id()Get the latest revision ID from form revisions.
get_delete_file_field_types()Returns an array of field types for which can uploaded files can be deleted.
delete_field_files()Deletes the uploaded files for the specified form and field.
get_physical_file_path()Gets the physical path of a file.
delete_field_from_confirmations()Deletes confirmation conditional logic rules based on the deleted field.
delete_field_from_notifications()Deletes notification routing and conditional logic rules based on the deleted field.
delete_field_from_conditional_logic()Deletes conditional logic rules based on the deleted field.
delete_lead()Deletes a lead.
add_note()Adds a note.
update_note()Updates a note.
delete_note()Deletes a note.
add_notification_note()Add note to entry containing the notification sending result
get_ip()Gets the IP to be used within the entry.
save_entry()Save Entry to database.
save_extra_field_meta()Gets the extra meta data a field wants to save to the entry and updates the entry meta with the retrieved data.
get_entry_meta_batch_processor()Creates a new instance of the entry meta batch operations handler if required and returns it.
add_properties_to_entry()Populates the supplied entry with missing properties.
add_meta_to_entry()Populates the supplied entry with missing meta.
hydrate_repeaters()Fill the repeater field with the entry data.
is_field_hidden()Check whether a field is hidden via conditional logic.
is_next_button_hidden()Determines if the next button was supposed to be hidden by conditional logic.
is_value_match()Determines if the field value matches the conditional logic rule value.
matches_conditional_operation()This method will evaluate the specified operation between the two specified values and return the result. If the two values match the operation, the method will return true. Otherwise, it will return false.
get_field_value()Returns the value for a field.
purge_expired_draft_submissions()Purges expired draft submissions.
delete_draft_submission()Deletes a draft submission.
save_draft_submission()Saves the draft submission.
update_draft_submission()Updates a draft submission.
get_uuid()Returns a UUID. Uses openssl_random_pseudo_bytes() if available and falls back to mt_rand().
get_draft_submission_values()Returns the values for the draft submission.
add_email_to_draft_sumbmission()Adds the email address to the draft submission.
maybe_trim_input()Returns the given value with leading and trailing whitespace removed if the value is not null or blank and trimming is enabled.
get_input_type()
get_custom_field_names()Retrieves the custom field names (meta keys) for the custom field select in the form editor.
prepare_value()Prepare the value before saving it to the lead. For multi-input fields this will be called for each input.
get_fileupload_value()
get_temp_filename()
process_post_template()Process any merge tags and shortcodes found in the template.
queue_save_input_value()Queues the input value for saving.
update_lead_field_value()Updates an existing field value in the database.
update_entry_field_value()Updates an existing field value in the database.
queue_batch_field_operation()Returns the SQL to update or insert field values..
has_batch_field_operations()Checks if any field updates, inserts, or deletions have been registered for batch processing.
commit_batch_field_operations()Performs the update, inserts and deletes registered by queue_batch_field_operation()
upload_file()
mu_drop_tables()Target for the wpmu_drop_tables filter. Adds all tables for Gravity Forms and the Add-On Framework to list
get_notes()Get a collection of notes.
get_lead_field_value()
get_leads_by_meta()
get_entries_by_meta()Searches entries by entry meta
get_entries_where_sql()Returns the WHERE clause for an entry search.
get_lead_ids()
get_label()
get_required_indicator()Get the text that tells the user that the field is required.
get_input()
get_current_page_url()Returns the URL of the current request.
get_field()Returns the field object for the requested field or input ID from the supplied or specified form.
get_sub_field()Returns the field inside a repeater field with the specified ID.
get_current_lead()Return the current lead being processed. Should only be called when a form has been submitted.
set_current_lead()Populates the the static $_current_lead property withh the given entry, for use in hooks where it is not explicitly passed.
convert_confirmation()Converts the legacy confirmation from forms created prior to v1.7 to the current format or adds the default confirmation.
get_default_confirmation()Returns a default confirmation.
delete_form_confirmation()Delete a form confirmation by ID.
remove_corrupt_confirmations()Remove corrupt confirmations created by old versions of GFFormsModel::convert_confirmation().
get_form_ids()Returns the ids of the specified forms.
get_forms_columns()Get forms and return any form column(s).
search_leads()
get_lead_db_columns()Returns the gf_entry table field names.
count_search_leads()
get_lead_count_all_forms()Returns the lead (entry) count for all forms.
get_entry_count_all_forms()Returns the entry count for all forms.
trim_form_meta_values()Trims values inside choice texts, choice values, input labels, field labels and field conditionalLogic
trim_conditional_logic_values()Trims values from an array of elements e.g. notifications and confirmations
trim_conditional_logic_values_from_element()Trims values from elements e.g. fields, notifications and confirmations
get_openssl_encrypted_fields()Returns an array of field IDs that have been encrypted using GFCommon::openssl_encrypt()
get_openssl_encrypted_fields_by_entries()Returns the encrypted field IDs for each entry_id specified in the $entry_ids array.
set_openssl_encrypted_fields()Adds the field IDs that have been encrypted using GFCommon::encrypt(). Merges the new IDs with the existing IDs.
is_openssl_encrypted_field()Checks whether the given field was encrypted using GFCommon::encrpyt() and registered using GFCommon::set_encrypted_fields()
get_accessible_properties()Adds accessible form settings to new forms. Checks if the values have been set before overriding.
get_fields_by_type()Returns an array containing the form fields of the specified type or types.
is_valid_operator()Checks whether the conditional logic operator passed in is valid.
update_recent_forms()Update the recent forms list for the current user when a form is edited or trashed.
get_recent_forms()Get the recent forms list for the current user.
get_draft_submissions()Returns all the draft submissions.
set_uploaded_files()Sanitizes the names of the files that have been uploaded to the tmp directory and sent in
entry_exists()Checks if an entry exists for the supplied ID.
id_exists_in_table()Checks if an id exists in the specified table.
get_addon_feed_db_columns()Returns an array of column names used by the gf_addon_feed table.
update_feed_property()Updates the specified feed with the given property value.
update_license_key()Updates the license key, If multisite, it updates the license key for all sites in the network.

Method Reference​

get_database_version()​

public static function get_database_version()

Returns the current database version.

Returns​

  • string

Since: 2.2

Source: forms_model.php:99

flush_current_forms()​

public static function flush_current_forms()

Flushes the data stored within GFFormsModel::$_current_forms.

Returns​

  • void

Since: Unknown

Source: forms_model.php:119

flush_current_lead()​

public static function flush_current_lead()

Flushes the data stored within GFFormsModel::$_current_lead.

Returns​

  • void

Since: Unknown

Source: forms_model.php:135

flush_current_form()​

public static function flush_current_form( $key )

Removes the cached properties, meta, and confirmations for a specific form.

Parameters​

NameTypeDefaultDescription
$key

Returns​

  • void

Since: 2.6

Source: forms_model.php:148

flush_confirmations()​

public static function flush_confirmations()

Flushes the data stored within GFFormsModel::$_confirmations

Returns​

  • void

Since: Unknown

Source: forms_model.php:162

get_form_table_name()​

public static function get_form_table_name()

Gets the form table name, including the site's database prefix.

Returns​

  • string — The form table name.

Since: Unknown

Source: forms_model.php:175

get_meta_table_name()​

public static function get_meta_table_name()

Gets the form meta table, including the site's database prefix.

Returns​

  • string — The form meta table.

Since: Unknown

Source: forms_model.php:194

get_form_view_table_name()​

public static function get_form_view_table_name()

Gets the form view table name, including the site's database prefix.

Returns​

  • string — The form view table name.

Since: Unknown

Source: forms_model.php:213

get_form_revisions_table_name()​

public static function get_form_revisions_table_name()

Gets the form revisions table name, including the site's database prefix.

Returns​

  • string — The form revisions table name.

Since: 2.4-dev

Source: forms_model.php:230

get_lead_table_name()​

public static function get_lead_table_name()

Gets the lead (entries) table name, including the site's database prefix.

Returns​

  • string — The lead (entry) table name.

Since: Unknown

Source: forms_model.php:245

get_lead_meta_table_name()​

public static function get_lead_meta_table_name()

Gets the lead (entry) meta table name, including the site's database prefix.

Returns​

  • string — The lead (entry) meta table name.

Since: Unknown

Source: forms_model.php:258

get_lead_notes_table_name()​

public static function get_lead_notes_table_name()

Gets the lead (entry) notes table name, including the site's database prefix.

Returns​

  • string — The lead (entry) notes table name.

Since: Unknown

Source: forms_model.php:271

get_lead_details_table_name()​

public static function get_lead_details_table_name()

Gets the lead (entry) details table name, including the site's database prefix.

Returns​

  • string — The lead (entry) details table name.

Since: Unknown

Source: forms_model.php:284

get_lead_details_long_table_name()​

public static function get_lead_details_long_table_name()

Gets the lead (entry) details long table name, including the site's database prefix.

Returns​

  • string — The lead (entry) details long table name.

Since: Unknown

Source: forms_model.php:297

get_lead_view_name()​

public static function get_lead_view_name()

Gets the lead (entry) view table name, including the site's database prefix.

Returns​

  • string — The lead (entry) view table name.

Since: Unknown

Source: forms_model.php:310

get_incomplete_submissions_table_name()​

public static function get_incomplete_submissions_table_name()

Gets the incomplete submissions table name, including the site's database prefix.

Returns​

  • string — he incomplete submissions table name.

Since: Unknown

Source: forms_model.php:323

get_entry_table_name()​

public static function get_entry_table_name()

Gets the entry table name, including the site's database prefix

Returns​

  • string — The entry table name

Source: forms_model.php:336

get_entry_meta_table_name()​

public static function get_entry_meta_table_name()

Gets the entry meta table name, including the site's database prefix

Returns​

  • string — The entry meta table name

Source: forms_model.php:351

get_entry_notes_table_name()​

public static function get_entry_notes_table_name()

Gets the lead (entry) notes table name, including the site's database prefix

Returns​

  • string — The lead (entry) notes table name

Source: forms_model.php:366

get_draft_submissions_table_name()​

public static function get_draft_submissions_table_name()

Gets the draft submissions table name, including the site's database prefix

Returns​

  • string — The draft submissions table name

Source: forms_model.php:382

get_rest_api_keys_table_name()​

public static function get_rest_api_keys_table_name()

Gets the REST API Key table name, including the site's database prefix

Returns​

  • string — The REST API Keys submissions table name

Source: forms_model.php:397

get_addon_feed_table_name()​

public static function get_addon_feed_table_name()

Returns the name of the table where add-on feeds are stored, including the site's database prefix.

Returns​

  • string

Since: 2.4.24

Source: forms_model.php:410

get_forms()​

public static function get_forms( $is_active=null, $sort_column='title', $sort_dir='ASC', $is_trash=false )

Gets all forms.

Parameters​

NameTypeDefaultDescription
$is_activeboolnullOptional. Defines if inactive forms should be displayed. Defaults to null.
$sort_columnstring'title'Optional. The column to be used for sorting the forms. Defaults to 'title'.
$sort_dirstring'ASC'Optional. Defines the direction that sorting should occur. Defaults to 'ASC' (ascending). Use 'DESC' for descending.
$is_trashboolfalseOptional. Defines if forms within the trash should be displayed. Defaults to false.

Returns​

  • array — $forms All forms found.

Since: Unknown

Source: forms_model.php:436

search_forms()​

public static function search_forms( $query='', $is_active=null, $sort_column='title', $sort_dir='ASC', $is_trash=false )

Searches form titles based on query.

Parameters​

NameTypeDefaultDescription
$querystring''Optional. The query to search.
$is_activeboolnullOptional. Defines if inactive forms should be displayed. Defaults to null.
$sort_columnstring'title'Optional. The column to be used for sorting the forms. Defaults to 'title'.
$sort_dirstring'ASC'Optional. Defines the direction that sorting should occur. Defaults to 'ASC' (ascending). Use 'DESC' for descending.
$is_trashboolfalseOptional. Defines if forms within the trash should be displayed. Defaults to false.

Returns​

  • array — $forms All forms found.

See Also​

  • GFFormsModel::get_form_table_name
  • GFFormsModel::get_form_db_columns
  • GFFormsModel::get_entry_count_per_form
  • GFFormsModel::get_view_count_per_form

Source: forms_model.php:511

get_entry_count_per_form()​

public static function get_entry_count_per_form()

Gets the number of entries per form.

First attempts to read from cache. If unavailable, gets the entry count, caches it, and returns it.

Returns​

  • array — $entry_count Array of forms, containing the form ID and the entry count

Since: Unknown

Source: forms_model.php:587

get_view_count_per_form()​

public static function get_view_count_per_form()

Gets the number of views per form

Checks the cache first. If not there, gets the count from the database, stores it in the cache, and returns it.

Returns​

  • array — $view_count Array of forms, containing the form ID and the view count

Since: Unknown

Source: forms_model.php:623

get_form_db_columns()​

public static function get_form_db_columns()

Returns the form database columns.

Returns​

  • array — The column IDs

Since: Unknown

Source: forms_model.php:646

get_form_payment_totals()​

public static function get_form_payment_totals( $form_id )

Gets the payment totals for a particular form ID.

Parameters​

NameTypeDefaultDescription
$form_idintThe form ID to get payment totals for.

Returns​

  • array — $totals The payment totals found.

Since: Unknown

Source: forms_model.php:663

get_form_counts()​

public static function get_form_counts( $form_id )

Gets the total, unread, starred, spam, and trashed entry counts.

Parameters​

NameTypeDefaultDescription
$form_idintThe ID of the form to check.

Returns​

  • array — $results[0] The form counts.

Since: Unknown

Source: forms_model.php:710

get_form_summary()​

public static function get_form_summary()

Gets the form summary for all forms.

Returns​

  • array — $forms Contains the form summary for all forms.

Since: Unknown

Source: forms_model.php:796

get_form_count()​

public static function get_form_count()

Gets the total, active, inactive, and trashed form counts.

Returns​

  • array — The form counts.

Since: Unknown

Source: forms_model.php:883

get_form_id()​

public static function get_form_id( $form_title )

Gets the form ID based on the form title.

Parameters​

NameTypeDefaultDescription
$form_titlestringThe form title to search for.

Returns​

  • int — The form ID. Returns 0 if not found.

Since: Unknown

Source: forms_model.php:928

get_form_cache_key()​

public static function get_form_cache_key( $form_id )

Returns the cache key for the specified form.

Parameters​

NameTypeDefaultDescription
$form_idintThe form ID.

Returns​

  • string

Since: 2.7

Source: forms_model.php:949

get_form()​

public static function get_form( $form_id, $allow_trash=false )

Returns an object containing the properties of the specified form or false if the form doesn't exist.

Parameters​

NameTypeDefaultDescription
$form_idintThe ID of the form to get.
$allow_trashboolfalseOptional. Set to true to allow trashed results. Defaults to false.

Returns​

  • bool | object

Since:

  • Unknown
  • 2.7 (Updated to cache the result.)

Source: forms_model.php:964

unserialize()​

public static function unserialize( $string )

Converts a serialized string or JSON for access in PHP.

Parameters​

NameTypeDefaultDescription
$stringstringThe string to convert.

Returns​

  • mixed

Since: Unknown

Source: forms_model.php:1005

get_form_meta()​

public static function get_form_meta( $form_id )

Gets the form meta based on the form ID.

Parameters​

NameTypeDefaultDescription
$form_idintThe form ID.

Returns​

  • array | null — $form Form object if found. Null if not found.

Since: Unknown

Source: forms_model.php:1034

has_legacy_markup()​

public static function has_legacy_markup()

Query request checking if the site contains any forms with Legacy markup.

Since: 2.9.1

Source: forms_model.php:1109

get_next_field_id()​

public static function get_next_field_id( $fields, $next_field_id=1 )

Recursively checks the highest ID for all the fields in the form and then returns the highest ID + 1.

Parameters​

NameTypeDefaultDescription
$fieldsGF_Field[]
$next_field_idint1

Returns​

  • int

Since: 2.4.6.12

Source: forms_model.php:1133

convert_field_objects()​

public static function convert_field_objects( $form )

Converts all field objects in a form, based on field type.

Parameters​

NameTypeDefaultDescription
$formarrayThe Form object.

Returns​

  • array — $form The Form object after the field objects are converted.

Since: Unknown

Source: forms_model.php:1161

get_form_meta_by_id()​

public static function get_form_meta_by_id( $ids )

Gets the form meta for multiple forms based on an array for form IDs.

Parameters​

NameTypeDefaultDescription
$idsarrayArray of form IDs.

Returns​

  • array — $results

Since: Unknown

Source: forms_model.php:1251

get_grid_column_meta()​

public static function get_grid_column_meta( $form_id )

Gets the column info for the entry listing page.

Parameters​

NameTypeDefaultDescription
$form_idintThe ID of the form that entries are coming from.

Returns​

  • mixed

Since: Unknown

Source: forms_model.php:1456

update_form_active()​

public static function update_form_active( $form_id, $is_active )

Updates the form is_active property in the database.

Parameters​

NameTypeDefaultDescription
$form_idintThe ID of the form to be updated.
$is_activeint | boolIndicates if the form is being set as active.

Returns​

  • void

Since:

  • unknown
  • 2.7 (Updated to clear the form from the cache.)

Source: forms_model.php:1497

change_entries_status()​

public static function change_entries_status( $leads, $status )

Changes the status of multiple entries.

Parameters​

NameTypeDefaultDescription
$leadsarrayThe entries to transition.
$statusstringThe new status.

Returns​

  • void

Since: 2.9.0

Source: forms_model.php:1605

change_entry_status()​

public static function change_entry_status( $lead_id, $status )

Changes the status of a single entry.

Parameters​

NameTypeDefaultDescription
$lead_idintThe entry ID.
$statusstringThe new status.

Returns​

  • void

Since: 2.9.0

Source: forms_model.php:1622

restore_entry_status()​

public static function restore_entry_status( $lead_id )

Restores the status of a single entry to its previous status.

Parameters​

NameTypeDefaultDescription
$lead_idintThe entry ID.

Returns​

  • void

Since: 2.9.0

Source: forms_model.php:1646

restore_entries_status()​

public static function restore_entries_status( $leads )

Restores the status of multiple entries to their previous status.

Parameters​

NameTypeDefaultDescription
$leadsarrayThe entries to restore.

Returns​

  • void

Since: 2.9.0

Source: forms_model.php:1670

delete_leads()​

public static function delete_leads( $leads )

Parameters​

NameTypeDefaultDescription
$leads

Source: forms_model.php:1761

delete_views()​

public static function delete_views( $form_id )

Delete the views for the specified form.

Parameters​

NameTypeDefaultDescription
$form_idintThe form ID.

Source: forms_model.php:1878

duplicate_form()​

public static function duplicate_form( $form_id )

Duplicate form.

Parameters​

NameTypeDefaultDescription
$form_idintForm ID to duplicate.

Returns​

Source: forms_model.php:2026

maybe_increment_title()​

public static function maybe_increment_title( $title, $form_id='' )

If a form title isn't unique, add a number to it to make it unique.

Parameters​

NameTypeDefaultDescription
$titlestring
$form_idint | string''

Returns​

  • string

Since: 2.5

Source: forms_model.php:2093

update_form_meta()​

public static function update_form_meta( $form_id, $form_meta, $meta_name='display_meta' )

Update form meta.

Parameters​

NameTypeDefaultDescription
$form_idintForm id.
$form_metaarrayForm meta.
$meta_namestring'display_meta'Meta name.

Returns​

  • false | int — Number of rows affected/selected or false on error.

Since: 2.4 (Added the form revision creation functionality.)

Source: forms_model.php:2165

maybe_create_form_revision()​

public static function maybe_create_form_revision( $new_display_meta, $form_id )

Create form revision if conditions met.

Parameters​

NameTypeDefaultDescription
$new_display_metaarrayForm meta.
$form_idintForm ID.

Since: 2.4

Source: forms_model.php:2206

get_latest_form_revisions_id()​

public static function get_latest_form_revisions_id( $form_id )

Get the latest revision ID from form revisions.

Parameters​

NameTypeDefaultDescription
$form_idintForm ID.

Returns​

  • int — Revision ID.

Since: 2.4

Source: forms_model.php:2294

get_delete_file_field_types()​

public static function get_delete_file_field_types( $form )

Returns an array of field types for which can uploaded files can be deleted.

Parameters​

NameTypeDefaultDescription
$formarrayThe current form.

Returns​

  • array

Since: 2.4.6.1

Source: forms_model.php:2367

delete_field_files()​

public static function delete_field_files( $form_id, $field_id )

Deletes the uploaded files for the specified form and field.

Note: Does not delete the file URLs from the entries, that is done by GFFormsModel::delete_field_values().

Parameters​

NameTypeDefaultDescription
$form_idintThe current form ID.
$field_idintThe ID of field being deleted.

Since:

  • 2.4.6.1
  • 2.5.16 (changed the query to return entry ID as well.)

Source: forms_model.php:2393

get_physical_file_path()​

public static function get_physical_file_path( $url, $entry_id=null )

Gets the physical path of a file.

Parameters​

NameTypeDefaultDescription
$urlstring
$entry_idinteger | nullnull

Returns​

  • string

Since:

  • unknown
  • 2.5.16 (Added optional $entry_id parameter.)

Source: forms_model.php:2546

delete_field_from_confirmations()​

public static function delete_field_from_confirmations( $form, $field_id )

Deletes confirmation conditional logic rules based on the deleted field.

Parameters​

NameTypeDefaultDescription
$formarrayThe form containing the confirmations to be processed.
$field_idintThe ID of the field being deleted.

Returns​

  • array

Since: 2.4.6.1

Source: forms_model.php:2668

delete_field_from_notifications()​

public static function delete_field_from_notifications( $form, $field_id )

Deletes notification routing and conditional logic rules based on the deleted field.

Parameters​

NameTypeDefaultDescription
$formarrayThe form containing the notifications to be processed.
$field_idintThe ID of the field being deleted.

Returns​

  • array

Since: 2.4.6.1

Source: forms_model.php:2702

delete_field_from_conditional_logic()​

public static function delete_field_from_conditional_logic( $logic, $field_id )

Deletes conditional logic rules based on the deleted field.

If no rules remain following the deletion conditional logic is disabled.

Parameters​

NameTypeDefaultDescription
$logicarrayThe conditional logic object to be processed.
$field_idintThe ID of the field being deleted.

Returns​

  • null | array

Since: 2.4.6.1

Source: forms_model.php:2754

delete_lead()​

public static function delete_lead( $lead_id )

Deletes a lead.

Parameters​

NameTypeDefaultDescription
$lead_id

Source: forms_model.php:2817

add_note()​

public static function add_note( $entry_id, $user_id, $user_name, $note, $note_type='user', $sub_type=null )

Adds a note.

Parameters​

NameTypeDefaultDescription
$entry_idintID of the entry to add the note to.
$user_idintID of the user who created the note.
$user_namestringName of the user who created the note.
$notestringText of the note.
$note_typestring'user'Note type.
$sub_typenullnullNote sub-type.

Returns​

  • int — ID of the new note.

Since:

  • 2.4.18 (Return statement added.)
  • unknown

Source: forms_model.php:2877

update_note()​

public static function update_note( $note_id, $entry_id, $user_id, $user_name, $date_created, $note, $note_type='user', $sub_type=null )

Updates a note.

Parameters​

NameTypeDefaultDescription
$note_idintID of the note to update.
$entry_idintID of the entry to add the note to.
$user_idintID of the user who created the note.
$user_namestringName of the user who created the note.
$date_createdstringDate and time the note was created in SQL datetime format.
$notestringText of the note.
$note_typestring'user'Note type.
$sub_typenullnullNote sub-type.

Returns​

  • string

Since: 2.4.18

Source: forms_model.php:2925

delete_note()​

public static function delete_note( $note_id )

Deletes a note.

Parameters​

NameTypeDefaultDescription
$note_idint ID of the note to delete.

Returns​

  • bool | int — Success or failure.

Since:

  • 2.4.18 (Return statement added.)
  • unknown

Source: forms_model.php:2966

add_notification_note()​

public static function add_notification_note( $entry_id, $result, $notification, $error_info='', $email=[], $note_args=[] )

Add note to entry containing the notification sending result

Parameters​

NameTypeDefaultDescription
$entry_idintegerId number for entry being processed.
$resultstring | booleanThe result returned by wp_mail().
$notificationarrayThe notification properties.
$error_infostring''Additional details for notifications with error.
$emailarray[]Array containing email details.
$note_argsarray[]Array containing text, type and subtype for the note.

Since: 2.4.14

Source: forms_model.php:3014

get_ip()​

public static function get_ip()

Gets the IP to be used within the entry.

Returns​

  • string — The IP to be stored in the entry.

Since: 2.2 (Using $_SERVER['REMOTE_ADDR'].)

Source: forms_model.php:3067

save_entry()​

public static function save_entry( $form, &$entry )

Save Entry to database.

Parameters​

NameTypeDefaultDescription
$formarrayForm object.
&$entryarrayEntry object.

Since:

  • 2.4.8.13 (Updated created_by property to save as an empty value when undefined.)
  • Unknown

Source: forms_model.php:3102

save_extra_field_meta()​

public static function save_extra_field_meta( $field, $form, $entry )

Gets the extra meta data a field wants to save to the entry and updates the entry meta with the retrieved data.

This method depends on batch operations, so begin_batch_entry_meta_operations should be called before this method is called and commit_batch_entry_meta_operations should be called after.

Parameters​

NameTypeDefaultDescription
$fieldGF_FieldThe current field.
$formarrayThe form that contains the field.
$entryarrayThe entry that was saved.

Since: 2.5.16

Source: forms_model.php:3442

get_entry_meta_batch_processor()​

public static function get_entry_meta_batch_processor()

Creates a new instance of the entry meta batch operations handler if required and returns it.

Returns​

  • GF_Entry_Meta_Batch_Processor

Since: 2.5.16

Source: forms_model.php:3463

add_properties_to_entry()​

public static function add_properties_to_entry( &$entry )

Populates the supplied entry with missing properties.

Parameters​

NameTypeDefaultDescription
&$entryarrayThe partial or complete entry currently being updated.

Since: 2.4.5.8

Source: forms_model.php:3479

add_meta_to_entry()​

public static function add_meta_to_entry( &$entry )

Populates the supplied entry with missing meta.

Parameters​

NameTypeDefaultDescription
&$entryarrayThe partial or complete entry currently being updated.

Since: 2.4.5.8

Source: forms_model.php:3504

hydrate_repeaters()​

public static function hydrate_repeaters( &$entry, $form, $apply_filters=false )

Fill the repeater field with the entry data.

Parameters​

NameTypeDefaultDescription
&$entry
$form
$apply_filtersboolfalseWhether to apply the filter_input_value filter to the entry.

Since:

  • Unknown.
  • 2.5 (Added the $apply_filters parameter.)

Source: forms_model.php:3529

is_field_hidden()​

public static function is_field_hidden( $form, $field, $field_values, $lead=null )

Check whether a field is hidden via conditional logic.

Parameters​

NameTypeDefaultDescription
$formarrayForm object.
$fieldGF_FieldField object.
$field_valuesarrayDefault field values for this form. Used when form has not yet been submitted. Pass an array if no default field values are available/required.
$leadarraynullOptional, default is null. If lead object is available, pass the lead.

Returns​

  • mixed

Source: forms_model.php:3809

is_next_button_hidden()​

public static function is_next_button_hidden( $field, $form )

Determines if the next button was supposed to be hidden by conditional logic.

Parameters​

NameTypeDefaultDescription
$fieldGF_FieldThe page field containing the next button logic.
$formarrayThe current form.

Returns​

  • bool

Since: 2.9.25

Source: forms_model.php:3876

is_value_match()​

public static function is_value_match( $field_value, $target_value, $operation='is', $source_field=null, $rule=null, $form=null )

Determines if the field value matches the conditional logic rule value.

Parameters​

NameTypeDefaultDescription
$field_valuemixedThe field value to be checked.
$target_valuemixedThe conditional logic rule value.
$operationstring'is'The conditional logic rule operator.
$source_fieldnull | GF_FieldnullThe field the rule is based on.
$rulenull | arraynullThe conditional logic rule properties.
$formnull | arraynullThe current form.

Returns​

  • bool

Source: forms_model.php:3941

matches_conditional_operation()​

public static function matches_conditional_operation( $val1, $val2, $operation )

This method will evaluate the specified operation between the two specified values and return the result. If the two values match the operation, the method will return true. Otherwise, it will return false.

The method supports the following operations: is, isnot, greater_than or >, less_than or <, contains, starts_with, ends_with.

Parameters​

NameTypeDefaultDescription
$val1stringThe first value to be compared. Must be formatted as a valid number for greater_than and less_than operations.
$val2stringThe second value to be compared. Must be formatted as a valid number for greater_than and less_than operations.
$operationstringThe operation to be performed with the specified values.

Returns​

  • bool — Returns true if the two values match the specified operation. Otherwise, it will return false.

Since: 2.9.1

Source: forms_model.php:4045

get_field_value()​

public static function get_field_value( &$field, $field_values=[], $get_from_post=true )

Returns the value for a field.

Parameters​

NameTypeDefaultDescription
&$fieldGF_Field
$field_valuesarray[]
$get_from_postbooltrueWhether to get the value from the $_POST array as opposed to $field_values

Returns​

  • array | mixed | string

Source: forms_model.php:4169

purge_expired_draft_submissions()​

public static function purge_expired_draft_submissions( $expiration_days=30 )

Purges expired draft submissions.

Parameters​

NameTypeDefaultDescription
$expiration_daysint30

Returns​

  • false | int

Since: 2.4

Source: forms_model.php:4198

delete_draft_submission()​

public static function delete_draft_submission( $token )

Deletes a draft submission.

Parameters​

NameTypeDefaultDescription
$token

Returns​

  • false | int

Since: 2.4

Source: forms_model.php:4241

save_draft_submission()​

public static function save_draft_submission( $form, $entry, $field_values, $page_number, $files, $form_unique_id, $ip, $source_url, $resume_token='' )

Saves the draft submission.

Parameters​

NameTypeDefaultDescription
$form
$entry
$field_values
$page_number
$files
$form_unique_id
$ip
$source_url
$resume_tokenstring''

Returns​

  • bool | false | int | string

Since: 2.4

Source: forms_model.php:4267

update_draft_submission()​

public static function update_draft_submission( $resume_token, $form, $date_created, $ip, $source_url, $submission_json )

Updates a draft submission.

Parameters​

NameTypeDefaultDescription
$resume_tokenstringThe uuid of the draft submission to be updated.
$formarray
$date_createdstring
$ipstring
$source_urlstring
$submission_jsonstring

Returns​

  • bool | false | int | string

Since: 2.4

Source: forms_model.php:4427

get_uuid()​

public static function get_uuid( $s='' )

Returns a UUID. Uses openssl_random_pseudo_bytes() if available and falls back to mt_rand().

source: http://stackoverflow.com/questions/2040240/php-function-to-generate-v4-uuid

Parameters​

NameTypeDefaultDescription
$sstring''The separator e.g. '-'

Returns​

  • string

Source: forms_model.php:4468

get_draft_submission_values()​

public static function get_draft_submission_values( $resume_token )

Returns the values for the draft submission.

Parameters​

NameTypeDefaultDescription
$resume_token

Returns​

  • array | null | object

Since: 2.4

Source: forms_model.php:4509

add_email_to_draft_sumbmission()​

public static function add_email_to_draft_sumbmission( $token, $email )

Adds the email address to the draft submission.

Parameters​

NameTypeDefaultDescription
$token
$email

Returns​

  • false | int

Since: 2.4

Source: forms_model.php:4571

maybe_trim_input()​

public static function maybe_trim_input( $value, $form_id, $field )

Returns the given value with leading and trailing whitespace removed if the value is not null or blank and trimming is enabled.

Parameters​

NameTypeDefaultDescription
$valuestring | array | nullThe field value to be trimmed.
$form_idintThe ID of the form to which the field belongs.
$fieldGF_FieldThe field object the value belongs to.

Returns​

  • string | array | null

Since: unknown

Source: forms_model.php:4593

get_input_type()​

public static function get_input_type( $field )

Parameters​

NameTypeDefaultDescription
$fieldGF_Field

Returns​

  • string

Source: forms_model.php:4693

get_custom_field_names()​

public static function get_custom_field_names( $limit='' )

Retrieves the custom field names (meta keys) for the custom field select in the form editor.

Parameters​

NameTypeDefaultDescription
$limitstring''Optional. Limits the number of custom field names returned. Default is empty (no limit).

Returns​

  • array

Since:

  • unknown
  • 2.9.10 (Added the $limit parameter.)

Source: forms_model.php:4837

prepare_value()​

public static function prepare_value( $form, $field, $value, $input_name, $lead_id, $lead=[] )

Prepare the value before saving it to the lead. For multi-input fields this will be called for each input.

Parameters​

NameTypeDefaultDescription
$formmixed
$fieldGF_Field
$valuemixed
$input_namemixed
$lead_idmixedthe current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations)
$leadmixed[]passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function

Returns​

  • mixed

Source: forms_model.php:4924

get_fileupload_value()​

public static function get_fileupload_value( $form_id, $input_name )

Parameters​

NameTypeDefaultDescription
$form_id
$input_name

Source: forms_model.php:4964

get_temp_filename()​

public static function get_temp_filename( $form_id, $input_name )

Parameters​

NameTypeDefaultDescription
$form_id
$input_name

Source: forms_model.php:5016

process_post_template()​

public static function process_post_template( $template, $field_type, $post_images, $post_data, $form, $entry )

Process any merge tags and shortcodes found in the template.

Parameters​

NameTypeDefaultDescription
$templatestringThe template.
$field_typestringThe field type currently being processed. Possible values: post_custom_field, post_content, or post_title.
$post_imagesarrayThe uploaded post images.
$post_dataarrayThe post data prepared from the current entry.
$formarrayThe form currently being processed.
$entryarrayThe entry currently being processed.

Returns​

  • string

Source: forms_model.php:5359

queue_save_input_value()​

public static function queue_save_input_value( $value, $form, $field, &$lead, $current_fields, $input_id, $item_index='' )

Queues the input value for saving.

Parameters​

NameTypeDefaultDescription
$valuestring | array
$formarray
$fieldGF_Field
&$leadarray
$current_fieldsarray
$input_idstring
$item_indexstring''

Since: 2.4

Source: forms_model.php:5620

update_lead_field_value()​

public static function update_lead_field_value( $form, $lead, $field, $lead_detail_id, $input_id, $value )

Updates an existing field value in the database.

Parameters​

NameTypeDefaultDescription
$formarray
$leadarray
$fieldGF_Field
$lead_detail_idint
$input_idstring
$valuestring

Returns​

  • bool

Source: forms_model.php:5684

update_entry_field_value()​

public static function update_entry_field_value( $form, $entry, $field, $entry_meta_id, $input_id, $value, $item_index='' )

Updates an existing field value in the database.

Parameters​

NameTypeDefaultDescription
$formarray
$entryarray
$fieldGF_Field
$entry_meta_idint
$input_idstring
$valuestring
$item_index''

Returns​

  • bool

Since: 2.3

Source: forms_model.php:5702

queue_batch_field_operation()​

public static function queue_batch_field_operation( $form, &$entry, $field, $entry_meta_id, $input_id, $value, $item_index='' )

Returns the SQL to update or insert field values..

Parameters​

NameTypeDefaultDescription
$formarray
&$entryarray
$fieldGF_Field
$entry_meta_idint
$input_idstring
$valuestring
$item_indexstring''

Returns​

  • bool

Source: forms_model.php:5804

has_batch_field_operations()​

public static function has_batch_field_operations()

Checks if any field updates, inserts, or deletions have been registered for batch processing.

Returns​

  • bool

Since: 2.4.17

Source: forms_model.php:5855

commit_batch_field_operations()​

public static function commit_batch_field_operations()

Performs the update, inserts and deletes registered by queue_batch_field_operation()

Returns​

  • array — An array of results.

Source: forms_model.php:5875

upload_file()​

public static function upload_file( $form_id, $file )

Parameters​

NameTypeDefaultDescription
$form_id
$file

Source: forms_model.php:6004

mu_drop_tables()​

public static function mu_drop_tables( $drop_tables )

Target for the wpmu_drop_tables filter. Adds all tables for Gravity Forms and the Add-On Framework to list

of tables to drop when a site is deleted.

Parameters​

NameTypeDefaultDescription
$drop_tables

Returns​

  • array

Source: forms_model.php:6205

get_notes()​

public static function get_notes( $search_criteria=[], $sorting=null )

Get a collection of notes.

Parameters​

NameTypeDefaultDescription
$search_criteriaarray[]{ Array of search criteria.
$sortingnull | arraynull{ Array of sort key and direction.

Returns​

  • array | null | object

Since: 2.4.18

Source: forms_model.php:6371

get_lead_field_value()​

public static function get_lead_field_value( $lead, $field )

Parameters​

NameTypeDefaultDescription
$lead
$fieldGF_Field

Returns​

  • array | bool | mixed | string | null

Source: forms_model.php:6484

get_leads_by_meta()​

public static function get_leads_by_meta( $meta_key, $meta_value )

Parameters​

NameTypeDefaultDescription
$meta_key
$meta_value

Returns​

  • array

Source: forms_model.php:6526

get_entries_by_meta()​

public static function get_entries_by_meta( $meta_key, $meta_value )

Searches entries by entry meta

Parameters​

NameTypeDefaultDescription
$meta_key
$meta_value

Returns​

  • array

Since: 2.3

Source: forms_model.php:6540

get_entries_where_sql()​

public static function get_entries_where_sql( $args )

Returns the WHERE clause for an entry search.

This function is not used and is only included for backwards compatibility. Use GFAPI::count_entries() instead.

Parameters​

NameTypeDefaultDescription
$args

Returns​

  • string

Since: 2.3.0.1

Deprecated: 2.3.0.1

Source: forms_model.php:6615

get_lead_ids()​

public static function get_lead_ids( $form_id, $search, $star=null, $read=null, $start_date=null, $end_date=null, $status=null, $payment_status=null )

Parameters​

NameTypeDefaultDescription
$form_id
$search
$starnullnull
$readnullnull
$start_datenullnull
$end_datenullnull
$statusnullnull
$payment_statusnullnull

Returns​

  • array | string

Deprecated: 3.0.0.0

Source: forms_model.php:6692

get_label()​

public static function get_label( $field, $input_id=0, $input_only=false, $allow_admin_label=true )

Parameters​

NameTypeDefaultDescription
$fieldGF_Field
$input_idint0
$input_onlyboolfalse
$allow_admin_labeltrue

Returns​

  • string

Source: forms_model.php:6857

get_required_indicator()​

public static function get_required_indicator( $form_id )

Get the text that tells the user that the field is required.

Parameters​

NameTypeDefaultDescription
$form_id

Returns​

  • string — HTML required indicator.

Since: 2.5

Source: forms_model.php:6902

get_input()​

public static function get_input( $field, $id )

Parameters​

NameTypeDefaultDescription
$fieldGF_Field
$id

Returns​

  • array | null

Source: forms_model.php:6935

get_current_page_url()​

public static function get_current_page_url( $force_ssl=false )

Returns the URL of the current request.

Parameters​

NameTypeDefaultDescription
$force_sslboolfalseIndicates if the URL should start with https.

Returns​

  • string

Since:

  • Unknown
  • 2.9.1 (Updated to return the referring URL for requests made via admin-ajax.php.)
  • 3.1.1 (Updated to use the new Ajax current_page_url input as a fallback.)

Source: forms_model.php:6972

get_field()​

public static function get_field( $form_or_id, $field_id )

Returns the field object for the requested field or input ID from the supplied or specified form.

Parameters​

NameTypeDefaultDescription
$form_or_idarray | intThe Form Object or ID.
$field_idstring | intThe field or input ID.

Returns​

Since:

  • 2.3 (Updated to support being passed the form id or form object as the first parameter.)
  • unknown.

Source: forms_model.php:7025

get_sub_field()​

public static function get_sub_field( $repeater_field, $field_id )

Returns the field inside a repeater field with the specified ID.

Parameters​

NameTypeDefaultDescription
$repeater_fieldGF_Field_RepeaterThe repeater field.
$field_idintThe field ID.

Returns​

Since: 2.4

Source: forms_model.php:7072

get_current_lead()​

public static function get_current_lead( $form=[] )

Return the current lead being processed. Should only be called when a form has been submitted.

If called before the "real" lead has been saved to the database, uses self::create_lead() to create a temporary lead to work with.

Parameters​

NameTypeDefaultDescription
$formarray[]The form being processed or an empty array to get the form based on the ID from the gform_submit input.

Returns​

  • false | array

Since:

  • Unknown
  • 2.7.1 (Added the optional $form arg.)

Source: forms_model.php:7100

set_current_lead()​

public static function set_current_lead( $lead, $flush_cache=true )

Populates the the static $_current_lead property withh the given entry, for use in hooks where it is not explicitly passed.

Parameters​

NameTypeDefaultDescription
$leadarrayThe entry to be cached.
$flush_cachebooltrueIndicates if the contents of the static $_cache property should be flushed.

Since:

  • unknown
  • 2.9.16 (Added the $flush_cache param.)

Source: forms_model.php:7127

convert_confirmation()​

public static function convert_confirmation( $form )

Converts the legacy confirmation from forms created prior to v1.7 to the current format or adds the default confirmation.

Parameters​

NameTypeDefaultDescription
$formarrayThe form being processed.

Returns​

  • array

Since:

  • 1.7
  • 2.4.15 (Fixed corrupt confirmation being created when form doesn't have one to convert.)

Source: forms_model.php:7144

get_default_confirmation()​

public static function get_default_confirmation( $event='' )

Returns a default confirmation.

Parameters​

NameTypeDefaultDescription
$eventstring''The confirmation event. form_saved, form_save_email_sent, spam, or an empty string for the default form submission event.

Returns​

  • array

Since:

  • 2.4.15
  • 2.10.0 (Updated to include the default spam confirmation.)

Source: forms_model.php:7174

delete_form_confirmation()​

public static function delete_form_confirmation( $confirmation_id, $form_id )

Delete a form confirmation by ID.

Parameters​

NameTypeDefaultDescription
$confirmation_idstringThe confirmation to be deleted.
$form_idint | arrayThe form ID or Form Object form the confirmation being deleted.

Returns​

  • false | int — The result of the database operation.

Since: 2.5

Source: forms_model.php:7279

remove_corrupt_confirmations()​

public static function remove_corrupt_confirmations( $confirmations )

Remove corrupt confirmations created by old versions of GFFormsModel::convert_confirmation().

Parameters​

NameTypeDefaultDescription
$confirmationsmixedThe confirmations to be processed.

Returns​

  • array

Since: 2.4.15

Source: forms_model.php:7316

get_form_ids()​

public static function get_form_ids( $active=true, $trash=false, $sort_column='id', $sort_dir='ASC' )

Returns the ids of the specified forms.

Parameters​

NameTypeDefaultDescription
$activebool | nulltrueTrue if active forms are returned. False to get inactive forms. Null to ignore the is_active property. Defaults to true.
$trashbool | nullfalseTrue if trashed forms are returned. False to exclude trash. Null to ignore the is_trash property. Defaults to false.
$sort_columnstring'id'The column to sort the results on.
$sort_dirstring'ASC'The sort direction, ASC or DESC.

Returns​

  • array — of form IDs.

Since:

  • unknown
  • 2.5 (Added $sort_column and $sort_dir parameters.)
  • 2.5.8 (Added support for passing null for the $active and $trash args.)

Source: forms_model.php:7354

get_forms_columns()​

public static function get_forms_columns( $active=true, $trash=false, $sort_column='id', $sort_dir='ASC', $columns=['id'] )

Get forms and return any form column(s).

Parameters​

NameTypeDefaultDescription
$activebooltrueTrue if active forms are returned. False to get inactive forms. Defaults to true.
$trashboolfalseTrue if trashed forms are returned. False to exclude trash. Defaults to false.
$sort_columnstring'id'The column to sort the results on.
$sort_dirstring'ASC'The sort direction, ASC or DESC.
$columnsarray['id']The columns to return. Defaults to ['id']. Other options are 'title', 'date_created', 'is_active', 'is_trash'. 'date_updated' may be supported, depending on the Gravity Forms version.

Returns​

  • array — Forms indexed from 0 by SQL result row number. Each row is an associative array (column => value).

See Also​

Since: 2.7.5

Source: forms_model.php:7397

search_leads()​

public static function search_leads( $form_id, $search_criteria=[], $sorting=null, $paging=null )

Parameters​

NameTypeDefaultDescription
$form_id
$search_criteriaarray[]
$sortingnullnull
$pagingnullnull

Returns​

  • array

Source: forms_model.php:7479

get_lead_db_columns()​

public static function get_lead_db_columns()

Returns the gf_entry table field names.

Returns​

  • array

Since:

  • 2.3.2.13 (Added date_updated.)
  • unknown

Source: forms_model.php:7496

count_search_leads()​

public static function count_search_leads( $form_id, $search_criteria=[] )

Parameters​

NameTypeDefaultDescription
$form_id
$search_criteriaarray[]

Returns​

  • null | string

Source: forms_model.php:7529

get_lead_count_all_forms()​

public static function get_lead_count_all_forms( $status='active' )

Returns the lead (entry) count for all forms.

Parameters​

NameTypeDefaultDescription
$statusstring'active'

Returns​

  • null | string

Source: forms_model.php:7540

get_entry_count_all_forms()​

public static function get_entry_count_all_forms( $status='active' )

Returns the entry count for all forms.

Parameters​

NameTypeDefaultDescription
$statusstring'active'

Returns​

  • null | string

Source: forms_model.php:7551

trim_form_meta_values()​

public static function trim_form_meta_values( $form, &$form_updated=false )

Trims values inside choice texts, choice values, input labels, field labels and field conditionalLogic

Parameters​

NameTypeDefaultDescription
$formarrayForm object.
&$form_updatedboolfalseOutput parameter.

Returns​

  • array — $form

Source: forms_model.php:7682

trim_conditional_logic_values()​

public static function trim_conditional_logic_values( $meta_array, $form, &$updated=false )

Trims values from an array of elements e.g. notifications and confirmations

Parameters​

NameTypeDefaultDescription
$meta_arrayarrayForm object.
$formarrayForm object.
&$updatedboolfalseOutput parameter.

Returns​

  • array — $meta_array

Source: forms_model.php:7735

trim_conditional_logic_values_from_element()​

public static function trim_conditional_logic_values_from_element( $element, $form=[], &$updated=false )

Trims values from elements e.g. fields, notifications and confirmations

Parameters​

NameTypeDefaultDescription
$elementarrayForm object.
$formarray[]Form object.
&$updatedboolfalseOutput parameter.

Returns​

  • array — $element

Source: forms_model.php:7758

get_openssl_encrypted_fields()​

public static function get_openssl_encrypted_fields( $entry_id )

Returns an array of field IDs that have been encrypted using GFCommon::openssl_encrypt()

Parameters​

NameTypeDefaultDescription
$entry_id

Returns​

  • array | bool | mixed

Since: 2.3

Source: forms_model.php:7803

get_openssl_encrypted_fields_by_entries()​

public static function get_openssl_encrypted_fields_by_entries( $entry_ids )

Returns the encrypted field IDs for each entry_id specified in the $entry_ids array.

Parameters​

NameTypeDefaultDescription
$entry_idsarrayAn array of entry IDs.

Returns​

  • array — Returns an array with entry_id as the key and an array of field IDs (that have been encrypted using GFCommon::openssl_encrypt()) as the value.

Since: 2.6

Source: forms_model.php:7823

set_openssl_encrypted_fields()​

public static function set_openssl_encrypted_fields( $entry_id, $field_ids )

Adds the field IDs that have been encrypted using GFCommon::encrypt(). Merges the new IDs with the existing IDs.

Parameters​

NameTypeDefaultDescription
$entry_id
$field_ids

Returns​

  • bool

Since: 2.3

Source: forms_model.php:7851

is_openssl_encrypted_field()​

public static function is_openssl_encrypted_field( $entry_id, $field_id )

Checks whether the given field was encrypted using GFCommon::encrpyt() and registered using GFCommon::set_encrypted_fields()

Parameters​

NameTypeDefaultDescription
$entry_id
$field_id

Returns​

  • bool | mixed | void

Since: 2.3

Source: forms_model.php:7874

get_accessible_properties()​

public static function get_accessible_properties( $form_meta )

Adds accessible form settings to new forms. Checks if the values have been set before overriding.

Parameters​

NameTypeDefaultDescription
$form_metaarrayThe form meta to be processed.

Returns​

  • array — The processed form meta with accessible settings added.

Since: 3.0.0

Source: forms_model.php:7902

get_fields_by_type()​

public static function get_fields_by_type( $form, $types, $use_input_type=false, $recursive=true )

Returns an array containing the form fields of the specified type or types.

Parameters​

NameTypeDefaultDescription
$formarray
$typesarray | string
$use_input_typeboolfalse
$recursivebooltrueWhether to search recursively through nested fields (e.g. in a Repeater field). Default is true.

Returns​

Since:

  • 1.9.9.10
  • 3.0.0 (Added $recursive parameter)

Source: forms_model.php:8071

is_valid_operator()​

public static function is_valid_operator( $operator )

Checks whether the conditional logic operator passed in is valid.

Parameters​

NameTypeDefaultDescription
$operatorstringConditional logic operator.

Returns​

  • bool — true if a valid operator, false if not.

Since: 2.0.7.20 (Refactored and added filter gform_is_valid_conditional_logic_operator.)

Source: forms_model.php:8113

update_recent_forms()​

public static function update_recent_forms( $form_id, $trashed=false )

Update the recent forms list for the current user when a form is edited or trashed.

Parameters​

NameTypeDefaultDescription
$form_idintThe ID of the current form.
$trashedboolfalseIndicates if the form was trashed. Default is false, form was opened for editing.

Since:

  • 2.0.7.14
  • 2.9.12 (Removed the dependency on the admin toolbar being enabled.)

Source: forms_model.php:8138

get_recent_forms()​

public static function get_recent_forms( $current_user_id=0 )

Get the recent forms list for the current user.

Parameters​

NameTypeDefaultDescription
$current_user_idint0The ID of the currently logged in user.

Returns​

  • array

Since: 2.2.1.14

Source: forms_model.php:8168

get_draft_submissions()​

public static function get_draft_submissions()

Returns all the draft submissions.

Returns​

  • array | null | object — The query result.

Since: 2.4

Source: forms_model.php:8267

set_uploaded_files()​

public static function set_uploaded_files( $form_id )

Sanitizes the names of the files that have been uploaded to the tmp directory and sent in

$_POST['gform_uploaded_files'] and caches them in GFFormsModel::$uploaded_files.

Parameters​

NameTypeDefaultDescription
$form_idintThe ID of the form the submission is being processed for.

Returns​

  • array

Since:

  • 2.4.3.5
  • 2.9.18 (Added support for dynamically populated file URLs using the url key.)
  • 2.10.3 (Deprecated the string-based (file/basename) input value.)

Source: forms_model.php:8296

entry_exists()​

public static function entry_exists( $entry_id )

Checks if an entry exists for the supplied ID.

Parameters​

NameTypeDefaultDescription
$entry_idintThe ID to be checked.

Returns​

  • bool

Since:

  • 2.4.6
  • 2.4.24 (Updated to use GFFormsModel::id_exists_in_table().)

Source: forms_model.php:8384

id_exists_in_table()​

public static function id_exists_in_table( $id, $table )

Checks if an id exists in the specified table.

Parameters​

NameTypeDefaultDescription
$idintThe ID to be checked.
$tablestringThe table name, including the site's database prefix.

Returns​

  • bool

Since: 2.4.24

Source: forms_model.php:8398

get_addon_feed_db_columns()​

public static function get_addon_feed_db_columns()

Returns an array of column names used by the gf_addon_feed table.

Returns​

  • string[]

Since: 2.4.24

Source: forms_model.php:8418

update_feed_property()​

public static function update_feed_property( $feed_id, $property_name, $property_value )

Updates the specified feed with the given property value.

Parameters​

NameTypeDefaultDescription
$feed_idintThe ID of the feed being updated.
$property_namestringThe name of the property (column) being updated.
$property_valuemixedThe new value of the specified property.

Returns​

Since:

  • 2.4.24
  • 2.7.17 (Added support for encrypting settings fields.)

Source: forms_model.php:8435

update_license_key()​

public static function update_license_key( $license )

Updates the license key, If multisite, it updates the license key for all sites in the network.

Parameters​

NameTypeDefaultDescription
$licensestringThe license key MD5.

Returns​

  • void

Since:

  • 2.7
  • 2.8.17 (Updated to also store the key as a network option.)

Source: forms_model.php:8488