Closed (fixed)
Project:
Webform
Version:
7.x-3.9
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Aug 2012 at 18:36 UTC
Updated:
18 Jun 2013 at 23:45 UTC
Is it possible to have a poll only among authenticated users, but such that any new submission from the user automatically overrides any previous ones by the same user?
This is different from http://drupal.org/node/152439, because while users can be allowed to edit their previous submission(s), such edit is a multi-step process, and not an automatic overwrite.
This has been asked here http://drupal.org/node/1215514.
Thanks
Comments
Comment #1
quicksketchIt may be possible to implement this, but it's not a built-in piece of functionality for the module. I believe this would be rather simple from an API standpoint. With a custom module you could use the hook_webform_submission_presave() hook to look up a user's current submission and set the SID. Then when the submission was saved to the database it would overwrite the previous submission (since having an SID means to do an update rather than an insert).
Comment #2
berenddeboer commentedI can't see presave working. I got duplicate key (sid) warnings.
To get this working, I implemented a hook_form_alter, and did something like:
Comment #3
quicksketchYep, it looks like that's the only approach that would work. Sorry for misleading you down an incorrect path. Sounds like you've got it figured out now, so I'm marking this fixed.