GFFormsModel
Class GFFormsModel
Handles database calls and formatting of stored data regarding forms
Source: forms_model.php:18
Details
- Kind:
class - Namespace:
(global)
Properties
| Property | Type | Description |
|---|---|---|
$uploaded_files | array | Defaults to an empty array. |
$unique_ids | array | Defaults to an empty array. |
Methods
| Method | Description |
|---|---|
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
| Name | Type | Default | Description |
|---|---|---|---|
$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
| Name | Type | Default | Description |
|---|---|---|---|
$is_active | bool | null | Optional. Defines if inactive forms should be displayed. Defaults to null. |
$sort_column | string | 'title' | Optional. The column to be used for sorting the forms. Defaults to 'title'. |
$sort_dir | string | 'ASC' | Optional. Defines the direction that sorting should occur. Defaults to 'ASC' (ascending). Use 'DESC' for descending. |
$is_trash | bool | false | Optional. 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
| Name | Type | Default | Description |
|---|---|---|---|
$query | string | '' | Optional. The query to search. |
$is_active | bool | null | Optional. Defines if inactive forms should be displayed. Defaults to null. |
$sort_column | string | 'title' | Optional. The column to be used for sorting the forms. Defaults to 'title'. |
$sort_dir | string | 'ASC' | Optional. Defines the direction that sorting should occur. Defaults to 'ASC' (ascending). Use 'DESC' for descending. |
$is_trash | bool | false | Optional. Defines if forms within the trash should be displayed. Defaults to false. |
Returns
array— $forms All forms found.
See Also
GFFormsModel::get_form_table_nameGFFormsModel::get_form_db_columnsGFFormsModel::get_entry_count_per_formGFFormsModel::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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_title | string | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The ID of the form to get. | |
$allow_trash | bool | false | Optional. Set to true to allow trashed results. Defaults to false. |
Returns
bool|object
Since:
Unknown2.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
| Name | Type | Default | Description |
|---|---|---|---|
$string | string | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The 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.