http://localhost/dt/node/124/submission/18
In this case, 124 is the node id while 18 is the submission id.
Now, on to the code.
$nid = 124;
$sid = 18;
$webform = node_load($nid);
$sub = webform_get_submission($nid, $sid);
// Capture the component IDs for easier array mapping.
foreach ($webform->components as $cid => $cfield) {
$components[$cfield['form_key']] = $cid;
}
// Retrieve user info
$user_info = new stdClass();
$user_info->username = $sub->data[$components['username']][0];
$user_info->email = $sub->data[$components['e_mail_address']][0];
// And the rest of your processing...
You can use this method to easily reference the fields stored in the row by field name instead of index number.
No comments:
Post a Comment