skip to Main Content

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.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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.';
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search