Ninja Forms - Import Submissions into Form with CSV/Excel

230 Views Asked by At

We are trying to find a way to import Submissions from an Excel/CSV File into our Ninja Form Submissions. Is there any way to add this functionality with Code?

We have been searching the Web for Solutions, Plugins, Code examples on how to add submissions, but we only found ways to change the values of the submissions but not add any new ones.

3

There are 3 best solutions below

2
Fabio Franco On

Importing submissions from an Excel/CSV file into Ninja Form Submissions might require a bit of coding magic, but you're on the right track.

You can definitely add this functionality through custom code – consider looking into Ninja Forms' API documentation or exploring WordPress hooks to create a custom solution that meets your needs.

First, read and parse the Excel/CSV file using a library like PHPExcel or fgetcsv. Then, loop through the data and use the Ninja Forms API functions to programmatically add new submissions. Utilize the ninja_forms_insert_submission() function and provide the necessary form data and field values.

Ensure you handle any validation or formatting required for the fields. Once the loop completes, you'll have successfully imported the submissions into Ninja Forms.

0
Alex Ammerman On

In the example, replace 'Value 1', 'Value 2', and so on with the actual values you want to insert for each form field. Also, make sure to replace 'field_key_1', 'field_key_2', and so on with the actual field keys for your form.

 // Assuming you have the form ID and the field values
$form_id = 1; // Replace with your form ID
$field_values = array(
    'field_key_1' => 'Value 1',
    'field_key_2' => 'Value 2',
    // Add more field values as needed
);

// Insert the submission
$ninja_forms_submission_id = ninja_forms_insert_submission($form_id, $field_values);

// Check if the submission was successful
if ($ninja_forms_submission_id) {
    echo 'Form submission successfully inserted with ID: ' . $ninja_forms_submission_id;
} else {
    echo 'Failed to insert form submission.';
}
0
Timothy Anderson On

If you are moving Ninja Forms submissions from one site to another, this can be done with the WordPress importer and exporter.

Dashboard > Tools > Import/Export

The form data is stored in 'submissions'.