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


  1. lydia
    Member

    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
    Lydia

    Posted 15 years ago #
  2. yuniar

    Hmm... how about disabling the form automatically after reached a set number of entries?
    This one would be possible.


    MachForm Founder

    Posted 14 years ago #
  3. lydia
    Member

    Hi Yuniar,

    great how do i automatically do that?

    thanks
    Lydia

    Posted 14 years ago #
  4. yuniar

    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 14 years ago #
  5. lydia
    Member

    thanks, i'll try this.

    Posted 14 years ago #
  6. fmolstad
    Member

    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 #
  7. yuniar

    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 #

RSS feed for this topic

Reply