This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
cap on entries - email notification
Started 15 years ago by lydia | 7 posts |
-
Hi,
Is it possible to receive an email notification that alarms you when the entries have reached a set number e.g. 100. Then i can go ahead and disable the form
thanks
LydiaPosted 15 years ago # -
Hmm... how about disabling the form automatically after reached a set number of entries?
This one would be possible.MachForm Founder
Posted 15 years ago # -
Hi Yuniar,
great how do i automatically do that?
thanks
LydiaPosted 15 years ago # -
Okay, let say you have a form with id number 7 and you would like to limit the entries to a maximum 100 entries.
Edit your "includes/post-functions.php" file, search around line 46:
$element_child_lookup['address'] = 5; $element_child_lookup['simple_name'] = 1; $element_child_lookup['name'] = 3;
above those lines, add this code:
//Start form limit code ----------------------- $form_limits[7] = 100; if(!empty($form_limits[$form_id])){ $entry_limit = $form_limits[$form_id]; $query = "select count(*) current_entry from ap_form_{$form_id}"; $result = do_query($query); $row = do_fetch_result($result); if($row['current_entry'] >= $entry_limit){ $process_result['status'] = false; $process_result['custom_error'] = "Sorry, this form is limited to {$entry_limit} entries."; do_query("update ap_forms set form_active='0' where form_id={$form_id}"); } } //End form limit code -------------------------
That should do it. Just make sure to adjust this value$form_limits[7] = 100; with your own value.
MachForm Founder
Posted 15 years ago # -
thanks, i'll try this.
Posted 15 years ago # -
Hello.
I was wondering if you had to use this code on more than one form.
Can this be pasted in the post-functions.php more than once.Or would I just add...
$form_limits[2] = 100;
$form_limits[6] = 100;
$form_limits[9] = 100;
$form_limits[21] = 100;...and then the if statement?
Forrest
Posted 13 years ago # -
Hi Forrest,
Yes, you can use the code for more than one form and you are doing it correctly with that code.
$form_limits[2] = 100; $form_limits[6] = 100; $form_limits[9] = 100; $form_limits[21] = 100;
those are the codes needed to use the limit on multiple forms.
The if statement doesn't need any change.MachForm Founder
Posted 13 years ago #
Reply
You must log in to post.