0

I am trying to update a webform submission from a form on the confirmation page. My callback function is as follows, but it's not updating the submission. What is the correct syntax to accomplish this? I'm getting the webform node and the submission are loaded correctly but the webform_submission_update is not updating the record. What am I doing wrong?

$nid = 3389;
$webform = node_load(3389);
$sid = $form['sid']['#default_value'];
module_load_include('inc', 'webform', 'includes/webform.submissions');
$submission = webform_get_submissions($nid, $sid);
$email = check_plain($form['your-email']['#value']);
$submission->data[14]['value'][0] = $email;
webform_submission_update($webform, $submission);
1

Looks like you are you using the wrong function, rather then retrieving a single webform submission you are retrieving multiple entries.

$nid = 3389;
$webform = node_load(3389);
$sid = $form['sid']['#default_value'];
module_load_include('inc', 'webform', 'includes/webform.submissions');
$submission = webform_get_submission($nid, $sid); // note function name
$email = check_plain($form['your-email']['#value']);
$submission->data[14]['value'][0] = $email;
webform_submission_update($webform, $submission);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.