0

I've this hook.

function modsubmit_webform_submission_insert($node, $submission) {
  $value = array_shift($submission->data);
  $value = array_shift($value['value']);
  print ($value);
  //$value is now the first value entered (in the case of multi-entry fields) or only value entered.
}

It does not print the message. Can anyone see what is wrong? Of course, the hook is called when the form is submitted.

1

Where are you wanting $value to be printed at?

Since this function runs in the background when a webform submission is inserted into the webform_submissions table, you need to be explicit about what you want to have happen. Try drupal_set_message() instead, to print a message into the $messages region upon the next successful page callback, which is likely the "submission successful" page:

function modsubmit_webform_submission_insert($node, $submission) {
  $value = array_shift($submission->data);
  $value = array_shift($value['value']);
  drupal_set_message("The value inserted was: {$value}");
}

Make sure you've installed this module and make sure that you've cleared your cache (admin/config/development/performance) if you've added this function to an existing, already-installed module.

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.