I have a content type "items" with a Select list field with the options 0|Free and 1|Reserved.

I am trying to change the fields value from 0 (default) to 1 when a certain webform is submitted (the webform gets the Nid from the url).

For this I have made (and enabled) a custom module (by following a tutorial I found) with the code below:

function reservable_item_change_status_webform_submission_insert($node,$submission) {
  if($node->nid == 5){ //my webform has an id of 5
    $nodeID = $submission->data[3]['value']['0'];
    $reservableItem = node_load($nodeID);
    if($reservableItem ->type == 'items'){
      $reservableItem->field_item_status['und'][0]['value'] = 1;

My problem is that nothing is happening. No errors, but the field status is not being changed to reserved.

I am using Webform version 3.2 because the tutorial stated it was meant for Webform 3.x. I will test with 4.x after I get this working.

Any help would be greatly appreciated.

  • For anyone else trying to get similar functionality to work in Webform 4.x you need to change $nodeID = $submission->data[3]['value']['0']; to $nodeID = $submission->data[3]['0']; as mentioned in the answer.
    – puudutus
    Commented Nov 5, 2015 at 8:42

1 Answer 1


If typo:

if($reservableItem ->type == 'items'){

change into:

if($reservableItem->type == 'items'){

In my implementation I get the submission values like:


So try to change it accordingly

  • Thanks for comment. I actually tried this both ways (cause was wondering the same thing). The way I wrote it here was how it was in the tutorial. But this didn't fix the issue.
    – puudutus
    Commented Nov 4, 2015 at 20:04
  • I tried $submission->data[3][0]. Same problem. Maybe the hook is not working at all for some reason?
    – puudutus
    Commented Nov 4, 2015 at 21:23
  • are you sure that node id is under $submission->data[3] ? It schould be in 3th input field in webform then Commented Nov 4, 2015 at 21:36
  • It is the 3rd input field in the webform. I'm just wondering how I start to debug this problem.. to see if the hook is working at all.
    – puudutus
    Commented Nov 5, 2015 at 5:56
  • 1
    Also, for anyone else trying to get similar functionality. Your implementation of getting submission values ($submission->data[3][0]) is required to make this work with Webform 4.x ($submission->data[3]['value']['0'] returns an php error).
    – puudutus
    Commented Nov 5, 2015 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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