1. Forminator API Docs
1.1 Method: initialize()
Copy chapter anchor to clipboardDescription
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.2 Method: get_forms()
Copy chapter anchor to clipboardDescription
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, you have two ways:
- 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
Example
Return
An array of form objects.
1.3 Method: get_form()
Copy chapter anchor to clipboardDescription
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
Example
Return
The form object.
1.4 Method: delete_form()
Copy chapter anchor to clipboardDescription
This method is used to delete a form from your list.
Usage
Forminator_API::delete_form( $form_id );
Parameters
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.5 Method: delete_forms()
Copy chapter anchor to clipboardDescription
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
Example
Return
TRUE => If the form is deleted
WP_ERROR => If there is an error to delete the form
1.6 Method: add_form()
Copy chapter anchor to clipboardDescription
This method is used to create a new form.
Usage
Forminator_API::add_form( ‘Form Test 3’, $wrappers, $settings );
Parameters
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.7 Method: update_form()
Copy chapter anchor to clipboardDescription
This method is used to update a form.
Usage
Forminator_API::update_form( 352, $wrappers, $settings );
Parameters
Example
Return
ID => ID of the updated form
WP_Error => The error if the form is not created
1.8 Method: get_polls()
Copy chapter anchor to clipboardDescription
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.9 Method: get_poll()
Copy chapter anchor to clipboardDescription
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
Example
Return
The poll object.
1.10 Method: delete_poll()
Copy chapter anchor to clipboardDescription
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
Example
Return
TRUE => If the poll is deleted
WP_ERROR => If there is an error to delete the poll
1.11 Method: delete_polls()
Copy chapter anchor to clipboardDescription
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
Example
Return
TRUE => If the poll is deleted
WP_ERROR => If there is an error to delete the poll
1.12 Method: add_poll()
Copy chapter anchor to clipboardDescription
This method is used to create a new poll.
Usage
Forminator_API::add_poll ( “Does it work?”, $answers, $settings );
Parameters
Example
Return
ID => ID of the create form
WP_Error => The error if the form is not created
1.13 Method: update_poll()
Copy chapter anchor to clipboardDescription
This method is used to update a poll.
Usage
Forminator_API::update_poll ( 352, $answers, $settings );
Parameters
Example
Return
ID => ID of the updated form
WP_Error => The error if the form is not updated
1.14 Method: get_quizzes()
Copy chapter anchor to clipboardDescription
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
Example
Return
An array of quiz objects.
1.15 Method: get_quiz()
Copy chapter anchor to clipboardDescription
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
Example
$quiz_id = 35;
$form = Forminator_API::get_ quiz( $quiz_id );
Return
The quiz object.
1.16 Method: delete_quiz()
Copy chapter anchor to clipboardDescription
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
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.17 Method: delete_quizzes()
Copy chapter anchor to clipboardDescription
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
Example
Return
TRUE => If the quiz is deleted
WP_ERROR => If there is an error to delete the quiz
1.18 Method: add_quiz()
Copy chapter anchor to clipboardDescription
This method is used to create a new quiz.
Usage
Forminator_API::add_quiz ( “Does it work?”, “knowledge”, $questions, $results, $settings );
Parameters
Example
Return
ID => ID of the create quiz
WP_Error => The error if the quiz is not created
1.19 Method: update_quiz()
Copy chapter anchor to clipboardDescription
This method is used to update a quiz.
Usage
Forminator_API::update_quiz( 352, $questions, $results, $settings );
Parameters
Example
Return
ID => ID of the updated quiz
WP_Error => The error if the quiz is not updated
1.20 Method: get_form_wrappers()
Copy chapter anchor to clipboardDescription
This method is used to retrieve all fields of a form.
Usage
Forminator_API::get_form_wrappers( 352 );
Parameters
Example
Return
ARRAY => Array of fields of a form
WP_Error => The error if the fields are not retrieved
1.21 Method: get_form_wrapper()
Copy chapter anchor to clipboardDescription
This method is used to retrieve a field of a form.
Usage
Forminator_API::get_form_wrapper( 352, ‘wrapper-1511347712118-1739’ );
Parameters
Example
Return
ARRAY => Array of the field properties of a form
WP_Error => The error if the field is not retrieved
1.22 Method: move_form_wrapper()
Copy chapter anchor to clipboardDescription
To move position of a form field
Usage
Forminator_API::move_form_wrapper( 352, ‘wrapper-1511347712118-1739’, 3 );
Parameters
Example
Return
ARRAY => Array of the field properties of a form
WP_Error => The error if the field is not retrieved
1.23 Method: delete_form_wrapper()
Copy chapter anchor to clipboardDescription
To delete a field of a form
Usage
Forminator_API::delete_form_wrapper( 352, ‘wrapper-1511347712118-1739’ );
Parameters
Example
Return
TRUE => If the form is deleted
WP_Error => The error if the field is not deleted
1.24 Method: get_form_fields()
Copy chapter anchor to clipboardDescription
This method is used to retrieve all fields of a form.
Usage
Forminator_API::get_form_fields( 352 );
Parameters
Example
Return
ARRAY => Array of fields of a form
WP_Error => The error if the fields are not retrieved
1.25 Method: get_form_fields_by_type()
Copy chapter anchor to clipboardDescription
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
Example
Return
ARRAY => Array of the fields of a form
WP_Error => The error if the fields are not retrieved
1.26 Method: get_form_field()
Copy chapter anchor to clipboardDescription
This method is used to retrieve a fields from a form by element ID
Usage
Forminator_API::get_form_field( 7, ’email-2′ );
Parameters
Example
Return
ARRAY => Array or object of the fields of a form
WP_Error => The error if the fields are not retrieved
1.27 Method: update_form_field()
Copy chapter anchor to clipboardDescription
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
Example
Return
There is nothing to return
1.28 Method: add_form_field()
Copy chapter anchor to clipboardDescription
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
Example
Return
There is nothing to return
1.29 Method: update_form_setting()
Copy chapter anchor to clipboardDescription
This method is used to update a setting element of a form
Usage
Forminator_API::update_form_setting( $form_id, $setting, $value );
Parameters
Example
Return
The ID of the form
1.30 Method: update_form_settings()
Copy chapter anchor to clipboardDescription
This method is used to update a setting element of a form
Usage
Forminator_API::update_form_setting( $form_id, $settings );
Parameters
Example
Return
The ID of the form
1.31 Method: delete_form_field()
Copy chapter anchor to clipboardDescription
This method is used to delete a field of a form
Usage
Forminator_API::delete_form_field( $form_id, $id )
Parameters
Example
Return
The ID of the deleted field
1.32 Method: delete_form_fields()
Copy chapter anchor to clipboardDescription
This method is used to delete multiple fields of a form
Usage
Forminator_API::delete_form_fields( $form_id, $field_ids )
Parameters
Example
Return
TRUE => If deleted
WP_ERROR => If it fails
1.33 Method: get_entries()
Copy chapter anchor to clipboardDescription
This method is used to get all entries of a form
Usage
Forminator_API::get_entries( $form_id );
Parameters
Example
Return
Forminator_Form_Entry_Model => If success
WP_ERROR => If it fails
1.34 Method: get_entry()
Copy chapter anchor to clipboardDescription
This method is used to get one entry of a form
Usage
Forminator_API::get_entry( $form_id, $entry_id );
Parameters
Example
Return
Forminator_Form_Entry_Model => If success
WP_ERROR => If it fails
1.35 Method: move_form_field()
Copy chapter anchor to clipboardDescription
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
Example
Return
The field object => If success
Field ID => If it fails
1.36 Method: delete_entry()
Copy chapter anchor to clipboardDescription
This method is used to delete an entry from the entry list
Usage
Forminator_API::delete_entry( $form_id, $entry_id );
Parameters
Example
Return
True => If success
WP_Error => If it fails
1.37 Method: delete_entries()
Copy chapter anchor to clipboardDescription
This method is used to delete an entry from the entry list
Usage
Forminator_API::delete_entries( $form_id, $entry_ids );
Parameters
Example
Return
True => If success
WP_Error => If it fails
1.38 Method: count_entries()
Copy chapter anchor to clipboardDescription
This method is used to get the number of total entries
Usage
Forminator_API::count_entries( $form_id )
Parameters
Example
Return
INT => If success
WP_Error => If it fails
1.39 Method: add_form_entry()
Copy chapter anchor to clipboardDescription
This method is used to add an entry to a form
Usage
Forminator_API::add_form_entry( $form_id, $entry_meta );
Parameters
Example
Return
INT => Entry ID
1.40 Method: update_form_entry()
Copy chapter anchor to clipboardDescription
This method is used to update an entry to a form
Usage
Forminator_API::update_form_entry( $form_id, $entry_id, $entry_meta );
Parameters
Example
Return
INT => Entry ID
1.41 Method: add_form_entries()
Copy chapter anchor to clipboardDescription
This method is used to add multiple entries to a form
Usage
Forminator_API::add_form_entries( $form_id, $entry_metas );
Parameters
Example
Return
INT => Entry ID
1.42 Method: add_poll_entry()
Copy chapter anchor to clipboardDescription
This method is used to add an entry to a poll
Usage
Forminator_API::add_poll_entry( $poll_id, $entry_meta );
Parameters
Example
Return
INT => Entry ID
1.43 Method: add_poll_entries()
Copy chapter anchor to clipboardDescription
This method is used to add multiple entries to a poll
Usage
Forminator_API::add_poll_entries( $poll_id, $entry_metas );
Parameters
Example
Return
INT => Entry ID
1.44 Method: update_poll_entry()
Copy chapter anchor to clipboardDescription
This method is used to update an entry to a form
Usage
Forminator_API::update_poll_entry( $poll_id, $entry_id, $entry_meta );
Parameters
Example
Return
INT => Entry ID
1.45 Method: add_quiz_entry()
Copy chapter anchor to clipboardDescription
This method is used to update an entry to a form
Usage
Forminator_API::add_quiz_entry( $quiz_id, $entry_meta );
Parameters
Example
Return
INT => Entry ID
1.46 Method: add_quiz_entries()
Copy chapter anchor to clipboardDescription
This method is used to update an entry to a form
Usage
Forminator_API::add_quiz_entries( $quiz_id, $entry_metas );
Parameters
Example
Return
INT => Entry ID
1.47 Settings Element
Copy chapter anchor to clipboardHere are some settings element that you can use in the settings array: