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

Limit number of Applications


  1. ddubell
    Member

    Is there a way to limit the number of applications that will be accepted? I only want to be able to accept 20 entries and want to have the form stop after that

    Posted 15 years ago #
  2. redityo

    Hi,

    You need to do small customization for this, edit your "post-functions.php" file and go to around line 880, you'll see this code :

    $process_result['error_elements'] = $error_elements;

    then add these code exactly bellow that line

    //limit the entries
    if ($form_id == 2) {
    	$query = "SELECT count(1) total_row FROM ap_form_{$form_id} ";
    	$result = do_query($query);
    	$row = do_fetch_result($result);
    
    	if ($row[0] >= 20) {
    		$process_result['custom_error'] = 'Sorry, this form limited to 3 entries.';
    	}
    }

    in there I set those logic only form id = 1, make sure you've change the ID with yours.


    MachForm Support

    Posted 15 years ago #
  3. primarytarget
    Member

    Excellent! Thank you! What if I wanted to set this limit for multiple forms. For example, 4 different forms, where I wanted to limit the entries to 20?

    Posted 15 years ago #
  4. redityo

    You can change the condition to be like this

    //limit the entries
    if ($form_id == 1 || $form_id == 2 || $form_id == 3 || $form_id == 4) {
    	$query = "SELECT count(1) total_row FROM ap_form_{$form_id} ";
    	$result = do_query($query);
    	$row = do_fetch_result($result);
    
    	if ($row[0] >= 20) {
    		$process_result['custom_error'] = 'Sorry, this form limited to 20 entries.';
    	}
    }

    that code will applied for form 1,2,3,4


    MachForm Support

    Posted 15 years ago #
  5. Juan
    Member

    Hi thank you for your excellent product.
    And if i have 4 forms with differents limits?
    Form 1 20 entries
    Form 2 50 entries
    Form 3 15 entries
    Form 4 12 entries

    Thabk you very much for your help

    Posted 12 years ago #
  6. AMurray
    Pro Member

    Juan.....this post is rather old (2 years...) and refers to a solution for Version 2 of Machform.

    If you have purchased Version 3 it makes this a lot simpler.

    Open the form, go to the Form properties (you may need to expand the 'more options' link) but there is an option there in the "protect and limit" options section - "Limit submission - "Maximum Accepted Entries : X" where "X" is the number of entries the form should accept before it shuts down / is disabled from accepting further entries.

    Posted 12 years ago #
  7. Juan
    Member

    Thank you very much, I found it ! ;o)

    Posted 12 years ago #
  8. barb080M
    Member

    Is it possible to limit the use per user of the form? For example, person 1 can only access it 10 times and person 2 can access it 12 times and so on.

    Posted 9 years ago #

RSS feed for this topic

Reply