1

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

0

It sounds like your webform has already been submitted by the time they reach checkout. So essentially, you may need to "Update" the submission with the new user ID.

Check out webform_submission_update: http://drupalcontrib.org/api/drupal/contributions!webform!includes!webform.submissions.inc/function/webform_submission_update/7

| improve this answer | |
  • Thank you for having responded to me, I saw the link that I have indicated, unfortunately, are a graphic design is not know so well the php, could you give me an example? – user3311699 Feb 8 '15 at 1:57
  • No one can help me? are beginning with drupal 7 and php. @NickyTheWrench – user3311699 Feb 10 '15 at 0:19

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.