WPMU DEV is dedicated to supporting advanced users in every possible way. Our Forminator API Documentation is an ongoing project. Information about new features will be added here as it becomes available.

General
To initialize the API
/library/class-api.php
To retrieve all or specific forms
/library/class-api.php
To retrieve a form
/library/class-api.php
To delete a form
/library/class-api.php
To delete all or specific forms
/library/class-api.php
To add a form
/library/class-api.php
To update a form
/library/class-api.php
To retrieve all polls
/library/class-api.php
To retrieve a poll
/library/class-api.php
To delete a poll
/library/class-api.php
To delete specific polls
/library/class-api.php
To add a poll
/library/class-api.php
To update a poll
/library/class-api.php
To retrieve all quizzes
/library/class-api.php
To retrieve a quiz
/library/class-api.php
To delete a quiz
/library/class-api.php
To delete specific quizzes
/library/class-api.php
To add a quiz
/library/class-api.php
To update a quiz
/library/class-api.php
To get all fields of a given form
/library/class-api.php
To get a field of a given form
/library/class-api.php
Move a field to a new position in a given form
/library/class-api.php
Delete a field of a given form
/library/class-api.php
To get all fields of a given form
/library/class-api.php
To get all fields of same type of a given form
/library/class-api.php
To get a field of a given form by element ID
/library/class-api.php
To update a field of a given form by element ID
/library/class-api.php
To add a field from a form by element ID
/library/class-api.php
To update a setting element of a given form
/library/class-api.php
To update setting elements of a given form
/library/class-api.php
To delete a field of a given form
/library/class-api.php
To delete multiple fields of a given form
/library/class-api.php
To get all entries of a given form
/library/class-api.php
To get one entry of a given form
/library/class-api.php
To get the latest entry of a given form
/library/class-api.php
To move a field to new position
/library/class-api.php
To delete an entry for a form
/library/class-api.php
To delete an entry for a form
/library/class-api.php
The total number of entries
/library/class-api.php
Add an entry to a form
/library/class-api.php
Update an entry for a form
/library/class-api.php
Add multiple entries to a form
/library/class-api.php
Add an entry to a poll
/library/class-api.php
Add multiple entries to a poll
/library/class-api.php
Update an entry to a poll
/library/class-api.php
Add an entry to a quiz
/library/class-api.php
Add multiple entries to a quiz
/library/class-api.php
The element properties of the settings
/library/class-api.php

1.1.1 Method: initialize()

Link to chapter 1

Description

This method is used for initializing the Forminator API. Though you don’t need to initialize when you use the API methods. Every methods in the API checks if this is initialized and if it is not, then it will initialize itself.

Usage

Forminator_API::initialize();

Parameters

It doesn’t have any parameters.

Return

There is nothing to return.

Example

Forminator_API::initialize();

1.1.2 Method: get_forms()

Link to chapter 1

Description

This method is used to get all the form objects. Those objects are instances of Forminator_Base_Form_Model class.

Usage

Forminator_API::get_forms();

  • If you don’t pass any parameter, then it will return all the form objects as an array.
  • To get specific forms, make an array of those form IDs and pass the array as parameter $form_ids
  • By default, it will return the 10 most recent forms. If you need more, also include $current_page and $per_page parameters.

Parameters

$form_ids
String | Array
The array of form IDs
$current_page
INT
Defaults to 1
$per_page
INT
The number of forms to return

Example

Return

An array of form objects.

1.1.3 Method: get_form()

Link to chapter 1

Description

This method will return the form object of the given form ID, it is an instance of Forminator_Base_Form_Model class.

Usage

Forminator_API::get_form( $form_id );

Parameters

$form_id
INT
The ID of the form

Example

Return

The form object.

1.1.4 Method: delete_form()

Link to chapter 1

Description

This method is used to delete a form from your list.

Usage

Forminator_API::delete_form( $form_id );

Parameters

$form_id
INT
The ID of the form

Example

$form = Forminator_API::delete_form( $form_id );

Return

TRUE => If the form is deleted
WP_ERROR => If there is an error to delete the form

1.1.5 Method: delete_forms()

Link to chapter 1

Description

This method is used to delete all the form objects of the given IDs.

Usage

Forminator_API::delete_forms( $form_ids );

  • Forminator_API::delete_forms( $form_ids );
    • Make an array of those form IDs and pass the array as parameter $form_ids
    • Pass all the IDs of the forms as separate parameters in that method

Parameters

$form_id
String | Array
The array of the form IDs

Example

Return

TRUE => If the form is deleted
WP_ERROR => If there is an error to delete the form

1.1.6 Method: add_form()

Link to chapter 1

Description

This method is used to create a new form.

Usage

Forminator_API::add_form( ‘Form Test 3’, $wrappers, $settings );

Parameters

$name
String
The name of the form
$wrappers
Array
The array of elements array with related parameters
$settings
Array
The array of settings options

Example

Some notes:

  • Wrapper ID should be unique and random numbers. The pattern is wrapper-xxxxxxxxxxx-yyyy where you can’t change wrapper, xxxxxxxxxxxx is a unique random number and yyyy is another unique and random number.
  • element_id should be unique too. So, if you have two text field, one should be text-1 and another one is text-2 and so on.
  • type is the field type, it could be name, email, text, phone etc
  • cols should be 12 if you want a field in one column. To keep two fields in one column, give the value 6 for cols parameter
  • $settings is an array of different settings element

Return

ID => ID of the create form
WP_Error => The error if the form is not created

1.1.7 Method: update_form()

Link to chapter 1

Description

This method is used to update a form.

Usage

Forminator_API::update_form( 352, $wrappers, $settings );

Parameters

$id
INT
The ID of the form
$wrappers
Array
The array of elements array with related parameters
$settings
Array
The array of settings options

Example

Return

ID => ID of the updated form
WP_Error => The error if the form is not created

1.1.8 Method: get_polls()

Link to chapter 1

Description

This method is used to get all the poll objects. Those objects are instances of Forminator_Base_Form_Model class.

Usage

Forminator_API::get_polls();

Parameters

There is no parameter

Example

Forminator_API::get_polls();

Return

An array of poll object

1.1.9 Method: get_poll()

Link to chapter 1

Description

This method will return the poll object of the given poll ID; it is an instance of Forminator_Base_Form_Model class.

Usage

Forminator_API::get_poll( $poll_id );

Parameters

$poll_id
INT
The ID of the poll

Example

Return

The poll object.

1.1.10 Method: delete_poll()

Link to chapter 1

Description

This method is used to delete a poll from your list.

Usage

Forminator_API::delete_poll( $poll_id );
Here $poll_id is the ID of the poll that you want to delete.

Parameters

$poll_id
INT
The ID of the poll

Example

Return

TRUE => If the poll is deleted
WP_ERROR => If there is an error to delete the poll

1.1.11 Method: delete_polls()

Link to chapter 1

Description

This method is used to delete the polls of the given IDs.

Usage

Forminator_API::delete_polls( $poll_ids );
Here $poll_ids is an array of poll IDs.

Parameters

$poll_ids
Array
The array of poll IDs

Example

Return

TRUE => If the poll is deleted
WP_ERROR => If there is an error to delete the poll

1.1.12 Method: add_poll()

Link to chapter 1

Description

This method is used to create a new poll.

Usage

Forminator_API::add_poll ( “Does it work?”, $answers, $settings );

Parameters

$name
String
The name of the form
$answers
Array
The array of answers with related parameters
$settings
Array
The array of settings options

Example

Return

ID => ID of the create form
WP_Error => The error if the form is not created

1.1.13 Method: update_poll()

Link to chapter 1

Description

This method is used to update a poll.

Usage

Forminator_API::update_poll ( 352, $answers, $settings );

Parameters

$id
INT
The ID of the form
$answers
Array
The array of answers with related parameters
$settings
Array
The array of settings options

Example

Return

ID => ID of the updated form
WP_Error => The error if the form is not updated

1.1.14 Method: get_quizzes()

Link to chapter 1

Description

This method is used to get all the quiz objects. Those objects are instances of Forminator_Base_Form_Model class.

Usage

Forminator_API::get_quizzes();

  • If you don’t pass any parameter, then it will return all the quiz objects as an array.
  • To get specific quizzes, you have two ways:
    • Make an array of those quiz IDs and pass the array as parameter $quiz_ids
    • Pass all the IDs of the forms as separate parameters in that method

Parameters

$quiz_ids
String | Array
The array of quiz IDs

Example

Return

An array of quiz objects.

1.1.15 Method: get_quiz()

Link to chapter 1

Description

This method will return the form object of the given quiz ID, it is an instance of Forminator_Base_Form_Model class.

Usage

Forminator_API::get_quiz( $quiz_id );

Here $quiz_id is the ID of the form that you want to fetch as an object.

Parameters

$quiz_id
INT
The ID of the quiz

Example

$quiz_id = 35;
$form = Forminator_API::get_ quiz( $quiz_id );

Return

The quiz object.

1.1.16 Method: delete_quiz()

Link to chapter 1

Description

This method is used to delete a quiz from your list.

Usage

Forminator_API::delete_quiz( $quiz_id );

Here $quiz_id is the ID of the quiz that you want to delete.

Parameters

$quiz_id
INT
The ID of the quiz

Example

$form = Forminator_API::delete_quiz( $quiz_id );

Return

TRUE => If the quiz is deleted
WP_ERROR => If there is an error to delete the quiz

1.1.17 Method: delete_quizzes()

Link to chapter 1

Description

This method is used to delete all the quiz objects of the given IDs.

Usage

Forminator_API::delete_quizzes( $quiz_ids );

  • To delete specific quizzes, you have two ways:
    • Make an array of those quiz IDs and pass the array as parameter $quiz_ids
    • Pass all the IDs of the quizzes as separate parameters in that method

Parameters

$quiz_ids
String | Array
The array of quiz IDs

Example

Return

TRUE => If the quiz is deleted
WP_ERROR => If there is an error to delete the quiz

1.1.18 Method: add_quiz()

Link to chapter 1

Description

This method is used to create a new quiz.

Usage

Forminator_API::add_quiz ( “Does it work?”, “knowledge”, $questions, $results, $settings );

Parameters

$name
STRING
The name of the quiz
$type
STRING
The type of the quiz
$questions
ARRAY
The array of question options
$result
ARRAY
The array of result options
$settings
ARRAY
The array of settings options

Example

Return

ID => ID of the create quiz
WP_Error => The error if the quiz is not created

1.1.19 Method: update_quiz()

Link to chapter 1

Description

This method is used to update a quiz.

Usage

Forminator_API::update_quiz( 352, $questions, $results, $settings );

Parameters

$id
INT
The ID of the quiz
$questions
Array
The array of question options
$result
Array
The array of result options
$settings
Array
The array of settings options

Example

Return

ID => ID of the updated quiz
WP_Error => The error if the quiz is not updated

1.1.20 Method: get_form_wrappers()

Link to chapter 1

Description

This method is used to retrieve all fields of a form.

Usage

Forminator_API::get_form_wrappers( 352 );

Parameters

$id
INT
The ID of the form

Example

Return

ARRAY => Array of fields of a form
WP_Error => The error if the fields are not retrieved

1.1.21 Method: get_form_wrapper()

Link to chapter 1

Description

This method is used to retrieve a field of a form.

Usage

Forminator_API::get_form_wrapper( 352, ‘wrapper-1511347712118-1739’ );

Parameters

$id
INT
The ID of the form
$form_id
STRING
The ID of the field wrapper

Example

Return

ARRAY => Array of the field properties of a form
WP_Error => The error if the field is not retrieved

1.1.22 Method: move_form_wrapper()

Link to chapter 1

Description

To move position of a form field

Usage

Forminator_API::move_form_wrapper( 352, ‘wrapper-1511347712118-1739’, 3 );

Parameters

$id
INT
The ID of the form
$form_id
STRING
The ID of the field wrapper
$new_position
INT
The new position of the field, starts with zero

Example

Return

ARRAY => Array of the field properties of a form
WP_Error => The error if the field is not retrieved

1.1.23 Method: delete_form_wrapper()

Link to chapter 1

Description

To delete a field of a form

Usage

Forminator_API::delete_form_wrapper( 352, ‘wrapper-1511347712118-1739’ );

Parameters

$form_id
STRING
The ID of the field wrapper
$id
INT
The ID of the form

Example

Return

TRUE => If the form is deleted
WP_Error => The error if the field is not deleted

1.1.24 Method: get_form_fields()

Link to chapter 1

Description

This method is used to retrieve all fields of a form.

Usage

Forminator_API::get_form_fields( 352 );

Parameters

$id
INT
The ID of the form

Example

Return

ARRAY => Array of fields of a form
WP_Error => The error if the fields are not retrieved

1.1.25 Method: get_form_fields_by_type()

Link to chapter 1

Description

This method is used to retrieve all fields from the same type in a form.

Usage

Forminator_API::get_form_fields_by_type( 352, ’email’ );

Parameters

$id
INT
The ID of the form
$type
STRING
The type of the field

Example

Return

ARRAY => Array of the fields of a form
WP_Error => The error if the fields are not retrieved

1.1.26 Method: get_form_field()

Link to chapter 1

Description

This method is used to retrieve a fields from a form by element ID

Usage

Forminator_API::get_form_field( 7, ’email-2′ );

Parameters

$form_id
INT
The ID of the form
$id
STRING
The elemend ID of the field
$to_array
BINARY
TRUE if the result is supposed to be an array, FALSE for object

Example

Return

ARRAY => Array or object of the fields of a form
WP_Error => The error if the fields are not retrieved

1.1.27 Method: update_form_field()

Link to chapter 1

Description

This method is used to update a fields from a form by element ID

Usage

Forminator_API::update_form_field( 7, ’email-2′, $data );

Parameters

$form_id
INT
The ID of the form
$id
STRING
The elemend ID of the field
$data
ARRAY
The array of the field element

Example

Return

There is nothing to return

1.1.28 Method: add_form_field()

Link to chapter 1

Description

This method is used to add a field from a form by element ID

Usage

Forminator_API::add_form_field( $form_id, $type, $data );

Parameters

$form_id
INT
The ID of the form
$type
STRING
The type of the field
$data
ARRAY
The array of the field element

Example

Return

There is nothing to return

1.1.29 Method: update_form_setting()

Link to chapter 1

Description

This method is used to update a setting element of a form

Usage

Forminator_API::update_form_setting( $form_id, $setting, $value );

Parameters

$form_id
INT
The ID of the form
$setting
STRING
The name of the setting
$value
STRING | ARRAY
The value of the setting

Example

Return

The ID of the form

1.1.30 Method: update_form_settings()

Link to chapter 1

Description

This method is used to update a setting element of a form

Usage

Forminator_API::update_form_setting( $form_id, $settings );

Parameters

$form_id
INT
The ID of the form
$settings
ARRAY
The element array

Example

Return

The ID of the form

1.1.31 Method: delete_form_field()

Link to chapter 1

Description

This method is used to delete a field of a form

Usage

Forminator_API::delete_form_field( $form_id, $id )

Parameters

$form_id
INT
The ID of the form
$id
STRING
The field ID

Example

Return

The ID of the deleted field

1.1.32 Method: delete_form_fields()

Link to chapter 1

Description

This method is used to delete multiple fields of a form

Usage

Forminator_API::delete_form_fields( $form_id, $field_ids )

Parameters

$form_id
INT
The ID of the form
$field_ids
ARRAY
The array of field IDs

Example

Return

TRUE => If deleted
WP_ERROR => If it fails

1.1.33 Method: get_entries()

Link to chapter 1

Description

This method is used to get all entries of a form

Usage

Forminator_API::get_entries( $form_id );

Parameters

$form_id
INT
The ID of the form

Example

Return

Forminator_Form_Entry_Model => If success
WP_ERROR => If it fails

1.1.34 Method: get_entry()

Link to chapter 1

Description

This method is used to get one entry of a form

Usage

Forminator_API::get_entry( $form_id, $entry_id );

Parameters

$form_id
INT
The ID of the form
$entry_id
INT
The ID of the entry

Example

Return

Forminator_Form_Entry_Model => If success
WP_ERROR => If it fails

1.1.35 Method: get_latest_entry_by_form_id()

Link to chapter 1

Description

This method is used to get the most recent entry of a form

Usage

Forminator_Form_Entry_Model::get_latest_entry_by_form_id( $form_id );

Parameters

$form_id
INT
The ID of the form

Example

Return

Forminator_Form_Entry_Model => If success
WP_ERROR => If it fails

1.1.36 Method: move_form_field()

Link to chapter 1

Description

This method is used to move a field from a position to a new position in a form

Usage

Forminator_API::move_form_field( $form_id, $id, $new_position, $new_wrapper_id );

Parameters

$form_id
INT
The ID of the form
$id
STRING
The ID of the field
$new_position
INT
The new position of the field
$new_wrapper_id
STRING
(optional) You can set a wrapper ID which identifies in which wrapper should the field moved

Example

Return

The field object => If success
Field ID => If it fails

1.1.37 Method: delete_entry()

Link to chapter 1

Description

This method is used to delete an entry from the entry list

Usage

Forminator_API::delete_entry( $form_id, $entry_id );

Parameters

$form_id
INT
The ID of the form
$entry_id
INT
The ID of the entry

Example

Return

True => If success
WP_Error => If it fails

1.1.38 Method: delete_entries()

Link to chapter 1

Description

This method is used to delete an entry from the entry list

Usage

Forminator_API::delete_entries( $form_id, $entry_ids );

Parameters

$form_id
INT
The ID of the form
$entry_ids
ARRAY
The array of IDs of the entries

Example

Return

True => If success
WP_Error => If it fails

1.1.39 Method: count_entries()

Link to chapter 1

Description

This method is used to get the number of total entries

Usage

Forminator_API::count_entries( $form_id )

Parameters

$form_id
INT
The ID of the form

Example

Return

INT => If success
WP_Error => If it fails

1.1.40 Method: add_form_entry()

Link to chapter 1

Description

This method is used to add an entry to a form

Usage

Forminator_API::add_form_entry( $form_id, $entry_meta );

Parameters

$form_id
INT
The ID of the form
$entry_meta
ARRAY
The array of entries

Example

Return

INT => Entry ID

1.1.41 Method: update_form_entry()

Link to chapter 1

Description

This method is used to update an entry to a form

Usage

Forminator_API::update_form_entry( $form_id, $entry_id, $entry_meta );

Parameters

$form_id
INT
The ID of the form
$entry_id
STRING
The ID of the entry
$entry_metas
ARRAY
The array of entries

Example

Return

bool | WP_ERROR

1.1.42 Method: add_form_entries()

Link to chapter 1

Description

This method is used to add multiple entries to a form

Usage

Forminator_API::add_form_entries( $form_id, $entry_metas );

Parameters

$form_id
INT
The ID of the form
$entry_metas
ARRAY
The array of array of entries

Example

Return

INT => Entry ID

1.1.43 Method: add_poll_entry()

Link to chapter 1

Description

This method is used to add an entry to a poll

Usage

Forminator_API::add_poll_entry( $poll_id, $entry_meta );

Parameters

$poll_id
INT
The ID of the form
$entry_metas
ARRAY
The array of entries

Example

Return

INT => Entry ID

1.1.44 Method: add_poll_entries()

Link to chapter 1

Description

This method is used to add multiple entries to a poll

Usage

Forminator_API::add_poll_entries( $poll_id, $entry_metas );

Parameters

$poll_id
INT
The ID of the poll
$entry_metas
ARRAY
The array of array of entries

Example

Return

INT => Entry ID

1.1.45 Method: update_poll_entry()

Link to chapter 1

Description

This method is used to update an entry to a form

Usage

Forminator_API::update_poll_entry( $poll_id, $entry_id, $entry_meta );

Parameters

$poll_id
INT
The ID of the poll
$entry_id
INT
The ID of the entry
$entry_meta
ARRAY
The array of entries

Example

Return

INT => Entry ID

1.1.46 Method: add_quiz_entry()

Link to chapter 1

Description

This method is used to update an entry to a form

Usage

Forminator_API::add_quiz_entry( $quiz_id, $entry_meta );

Parameters

$quiz_id
INT
The ID of the quiz
$entry_meta
ARRAY
The array of entries

Example

Return

INT => Entry ID

1.1.47 Method: add_quiz_entries()

Link to chapter 1

Description

This method is used to update an entry to a form

Usage

Forminator_API::add_quiz_entries( $quiz_id, $entry_metas );

Parameters

$quiz_id
INT
The ID of the quiz
$entry_metas
ARRAY
The array of array of entries

Example

Return

INT => Entry ID

1.1.48 Settings Element

Link to chapter 1

Here are some settings element that you can use in the settings array:

1.2 Modified or Deprecated Hooks

Copy chapter anchor to clipboard

This chapter contains information related to any actions or filters that may be modified or removed due to changes in plugin functionality.

Changes in Version 1.16.0

Version 1.16.0 introduces some performance improvements in the way form submissions are handled. These changes do not affect forms created using the plugin’s built-in options, but they can break forms that have been customized using deprecated actions & filters. Below is the list of such changes with this version:

Removed deprecated filters:

forminator_poll_chart_color

forminator_get_admin_email_recipients

forminator_poll_mail_admin_recipients

forminator_custom_form_mail_admin_recipients

forminator_email_field_custom_validation_message

Removed deprecated actions:

forminator_custom_form_before_handle_submit

forminator_custom_form_after_handle_submit

forminator_custom_form_before_save_entry

forminator_custom_form_after_save_entry

Removed filters:

forminator_custom_form_calculation_entry_data

forminator_custom_form_get_captcha_field

forminator_field_calculation_converted_formula

forminator_field_{$field_slug}_dummy_calculable_value

forminator_calculator_max_nested_formula

forminator_field_calculation_calculated_value

forminator_fields_to_array

Removed actions:

forminator_custom_form_after_calculate_field

forminator_custom_form_before_calculate_field

Renamed filters:

forminator_field_{$field_slug}_calculable_precision renamed to forminator_field_calculable_precision

forminator_custom_form_pseudo_submitted_data renamed to forminator_prepared_data

Changed filter attributes amount:

forminator_field_paypal_payment_amount

forminator_field_stripe_payment_amount

forminator_replace_form_data

forminator_form_settings

forminator_field_stripe_payment_amount

forminator_field_stripe_subscription_quantity

Changed action attributes amount:

forminator_cform_user_registered

If you still have questions or need assistance after reading this document, please don’t hesitate to contact our support superheroes using the available options under the Support tab in your Hub or via the Support tab in your WPMU DEV Dashboard.

Link to getting support