The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
Quota restriction - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: Quota restriction (/showthread.php?tid=967) |
Quota restriction - jacksonc@ust.hk - Dec 9th, 2010 First of all I would like to say FormTools is an excellent tool, have been using it over a year now. I was wondering is it possible to set a quota restriction on the form? Say if the quota exceeds the limit it will trigger a different auto-reply email? This is extremely useful when I use it as event registration form. Regards, Jackson Chan RE: Quota restriction - Ben - Dec 9th, 2010 Hi Jackson, Yeah, I can totally see the need for this. Unfortunately I can't think of any terribly good way to do this right now. But here's a hack way, in case you're curious. - Create a new field to your form called "is_full" (just within Form Tools - you don't need to add it to your actual form). - Create a new Submission Pre-Parser rule - see: http://modules.formtools.org/submission_pre_parser/ This would get triggered for all new submissions. In the code, I'd query the database, find out how many submissions have added so far and if it's over the total permissable # of registrations (say 400 or whatever) I'd set "is_full" to "yes". If not, set it to "no". - I'd then create two new Views: One called "Registration Full" and add a Standard Filter to limit all results in the View to only show those submissions with "is_full" set to "yes". The second called "Registration Open". This would be just like the other one, except only show submissions where "is_full" is set to "no". Lastly, all you'd need to do is map your email templates (the "thanks for registering!" and "sorry, registration full!" email templates) to those Views. That way they'll get sent only when a submission fits into one of those Views - i.e. when the registration is full or not. It's NOT great, obviously. But it would certainly work...! Let me know if you need any pointers. I kind of glossed over the SQL bit. ![]() - Ben RE: Quota restriction - jacksonc@ust.hk - Dec 9th, 2010 Dear Ben, Wow! Thank you so much for your reply. Yes I did take a look at the Submission Pre-Parser, but I didn't know you can do SQL query in there too. I thought it's only for form data processing. Your solution will definitely work, if I know how to put SQL query in the PHP code. Would you please give me a place to look for samples? Thank you so much. Regards, Jackson RE: Quota restriction - jacksonc@ust.hk - Dec 9th, 2010 Dear Ben, Another question, yes I understand we can set email triggers based on different views. But is there any way to "play" with the redirected page? (Thank you page), possible to redirects to different return message? Regards, Jackson RE: Quota restriction - jacksonc@ust.hk - Dec 13th, 2010 I'm still wondering how to "find out how many submissions have added so far", is there a var I can get this value? Thanks! RE: Quota restriction - Ben - Dec 18th, 2010 Hey Jackson, (Dec 13th, 2010, 7:31 PM)jacksonc@ust.hk Wrote: I'm still wondering how to "find out how many submissions have added so far", is there a var I can get this value? Sure! There's actually a handy Form Tools Core function for this. You can call it in either of these ways: PHP Code: $num_submissions = ft_get_submission_count($form_id); The first way returns the number of submissions in the form - the second, the number of submissions in a form View. In both cases, you'll need to pass the specific form ID and form View ID that you're interested in. You can use this core right in the Submission Pre-Parser rule. Quote:is there any way to "play" with the redirected page? (Thank you page), possible to redirects to different return message? Excellent question. Yes! There's a couple of ways. If you have a POST form, you can always include a hidden field: Code: <input type="hidden" name="form_tools_redirect_url" value="http://www.whatever.com" /> If that value is defined, the form will redirect to that URL and not the "redirect URL" value stored for the form. Basically it just lets you override the default value. Simililarly, you can also set that value in your Submission Pre-Parser rule to dynamically determine the redirect URL: PHP Code: $_POST["form_tools_redirect_url"] = "http://whatever.com"; To be perfectly honest, I haven't tried this in a while - but that was how I originally coded it and I don't think anything's changed. ![]() Anyway, let me know if you have any problems with the above or have any other questions! - Ben RE: Quota restriction - jacksonc@ust.hk - Dec 20th, 2010 Dear Ben, Fantastic !! You are wonderful, thank you so much !!!! Regards, Jackson RE: Quota restriction - jacksonc@ust.hk - Jan 5th, 2011 I've successfully implemented it and using it for Event Registration, works perfectly! RE: Quota restriction - Ben - Jan 6th, 2011 Congratulations!! ![]() |