On a site I administer there is a need to handle webform results, and have the admin view them, then convert some to content type. I am starting out with a custom module, have enabled the module, and trying to get the hook mymodule_webform_submission_presave to fire off when doing an edit, at this stage just print_r the $node and $submission, so I can see that it's getting that far, and what I have access to. However many times I edit and save the webform result with garbage data, I'm not getting the print_r happening.
mymodule_webform_submission_presave($node, &$submission) { print_r($node); print_r($submission); }
I've also tried _update.
Any clues what I'm doing wrong?
Use the second parameter for print_r to tell it to return the output so you can display it raw or using one of the numerous output functions. For example...
Also popular is using <pre> tag to format the output...
My preference is using devel's function, together with PHP's get_defined_vars ...
See https://www.php.net/manual/en/function.print-r.php ...
Also, this is often helpful when there is no place to display on the screen...
var_dump, var_export and print_r all have that same second parameter that returns structured output so it can be displayed or used as a string.
Being able to debug your $submission is key to webform development. You're on the right road.
Enjoy!