Hi there!

I'm planning to use this (excellent) module to have a simple way for admins of a site i'm building to give away invitations to events. The modules does the job (send email to them and tracking responses), however, It would be really useful to have an option to limit the maximum number of submissions.

A big plus would then be to have a way to show in the node the number of remaining possible submissions.

Any pointers on how to accomplish this? Or Am I using the wrong module?

thank you very much!

Comments

Rafał Ch’s picture

subscribe
it would be a great feature!

quicksketch’s picture

Category: feature » support

You could build this out manually with a little bit of work. In the additional submission code, try something like this:

  $count = db_result(db_query("SELECT count(*) FROM {webform_submissions} WHERE nid = %d", $node->nid));
  if ($count > 50) {
    $node->status = 0;
    node_save($node);
  }

This wouldn't be the perfect solution though because it'd make the entire form unaccessible by unpublishing it. We're working on a feature to enabled/disable submissions by role in #239343: No permission for 'create webform submission', but it's not yet finished. You could use the exact same approach, but disable submissions for all roles (effectively closing the form). So yes this is probably the right module, but the feature you need isn't finished yet.

vermario’s picture

ok thank you! if i don't manage to dissuade the client, i'll try your workaround. Thank you very much! :)

quicksketch’s picture

I'm closing this issue, but I wanted to say that there is now a method to "Close" webforms from more submissions without unpublishing the node entirely.

  $count = db_result(db_query("SELECT count(*) FROM {webform_submissions} WHERE nid = %d", $node->nid));
  if ($count > 50) {
    $node->webform['roles'] = array();
    node_save($node);
  }

Disabling all the roles for a webform "closes" the form from further submission.

shanefjordan’s picture

I tried this and it does not seem to work. If I have it change the status, it does change the status. It just doesn't "close" for further submissions.

- Shane

quicksketch’s picture

Make sure you're not User #1, who always has access to all forms.

shanefjordan’s picture

Status: Active » Fixed

I just did an upgrade from 5.-2.0 to 5.x-2.3 and now I see a listing of roles on the webform configuration page. I am going to guess that this will probably take care of the issue and if not, I will be sure to post back.

- Shane

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.