I needed to get the webform to let a user submit the form each day, no matter what time of day they were submitting it.

The way it works now, the user has to wait 24 hours from their last submission.

I remedied this by declaring a variable like this:

  $offset = (date("H") * 60 * 60);
  $offset += (date("i") * 60);

then replacing:

  $result = db_query($query, $user->uid, $_SERVER['REMOTE_ADDR'], $user->uid, ($node->webform['submit_interval'] != -1) ? time() - $node->webform['submit_interval'] : $node->webform['submit_interval'], $node->nid);

with:

  $result = db_query($query, $user->uid, $_SERVER['REMOTE_ADDR'], $user->uid, ($node->webform['submit_interval'] != -1) ? time() - $node->webform['submit_interval'] + $offset : $node->webform['submit_interval'] + $offset, $node->nid);

and :

  if ($timestamp <= time() - $node->webform['submit_interval']) {

with:

  if ($timestamp <= time() - $node->webform['submit_interval'] + $offset) {

Not sure if this is the best way, but it seems to work.

Comments

quicksketch’s picture

Thanks for the changes! I'd really like to add this as the default functionality of Webform, but working from the descriptions provided is a bit troublesome. Could you create a patch (http://drupal.org/patch/create) and I'll review it for inclusion in Webform?

betz’s picture

i need this also, but for d6.
I will have a look for it

betz’s picture

looks like everything changed since then.
This code is not applicable

quicksketch’s picture

Status: Active » Closed (duplicate)