I'm a graphic design, and I just started using Drupal 7.
I have a form created with webform, which collects data entered by the user, after sending, the user is directed to the purchase page. The stages of the purchase is successful if both the user and logged in, whether the user is anonymous.
Here's my problem, from the control panel of Drupal 7 when I go to see the results of the webform, if the form has been sent by the user logged in, see the user's name, is so I know who did it then submitting the form. While it has been the anonymous user, in the results I see anonymous user even after the user has registered and recognized.
For clarity I describe what it does with this form, these are the steps that the user to fill out the form webform:
1) Fill out the form webform (in this form there two fields of the form "webform commerce") 2) after sending the form you will be directed during the cart / checkout, at this stage the user enters the email for the registration, if it is anonymous. Everything works perfectly.
I noticed that the field in the table webform_submission uid inside the database remains at 0 even after the user has registered.
Browsing around the net in the blog / forum / drupal.org I left this tutorials: example tutorial so I'm starting to use hook_webform_submission_presave in a custom form. So how do I fill the uid after the form has been sent?
This is the code:
<?php
/**
* @file
* Questo modulo server per collegare utente anonimo con il webform inviato.
*/
// hook per ottenere l'ID dell'utente che ha inviato il modulo webform
function mio_modulo_webform_submission_presave($node, &$submission) {
// Ottengo l'id dell'utente.
//$user = user_load($submission->uid);
global $user;
$user->uid;
}
?>
Sorry for my english Thanks in advance for the help