Extending drupal webform to export data remotely

337 views Asked by At

I am trying to extend the module webform to allow a user to export webform data. My question is: If for example I got 5 fields: Name, Surname, Address, Telephone, Email, when I do my export from the custom module that I am developing, I got to retrieve specific fields, example the first 3 fields' data, I need a way to retrieve the data from the webform. Can someone please suggest a way of retrieving these data from the webform module to my custom module. There's already a similar existing module https://www.drupal.org/project/webform_remote_post BUT it takes all the fields in the webform which is not similar my case.

1

There are 1 answers

0
Scott Anderson On

You may want to use the hook hook_webform_submission_insert().

function mymodule_hook_webform_submission_insert($node, $submission) {
   // Get data from $submission object
   $component_id = 4;
   $data = $submission->data[$component_id]['value'][0];
   // Do something with data
}

Use print_r() or dpm() to see the content of $submission and get the data you need.