When a user fills out a webform on my Drupal 7 site, on submitting, I need the submission data to be sent over to another database. I'm using hook_webform_submission_insert in a custom module, but I can only get the sid and nid to be inserted into the table. I need my webform fields to be sent also; like first_name, last_name, email, etc. But I get errors upon submitting.
<?php
function hook_webform_submission_insert($node, $submission) {
// Insert a record into a 3rd-party module table when a submission is added.
db_insert('mymodule_table')
->fields(array(
'nid' => $node->nid,
'sid' => $submission->sid,
'foo' => 'foo_data',
))
->execute();
}
?>
I've tried 'first_name' => 'first_name', but it doesn't work. What am I doing wrong?