PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Limit entries with count in field

  1. I used that build-in functionality to limit the number of entries allowed for my event and it works fine. Now I would like to add field "[ ] I have avec with me" -field the add two visitors to limit count at once. (I can also use select with counts if it's easier.)

    Is there any easy way to do this kind of calculation to get right count?

    Posted 11 years ago on Friday February 22, 2013 | Permalink
  2. David Peralty

    Gravity Forms does its entry limit by submitted entries, and you can't create two entries from one submission and Gravity Forms doesn't have an inventory system. A heavily customized version of the following might help: http://gravitywiz.com/better-inventory-with-gravity-forms/

    Posted 11 years ago on Friday February 22, 2013 | Permalink
  3. Thanks. I made quick and dirty solution by combining couple of examples

    function count_with_avecs($form){
    
      $count = 0;
      $leads = RGFormsModel::get_leads($form["id"]);
    
      foreach($leads as $id => $lead) {
    	$count++;
    	if( $lead['8.1'] == "KYLLÄ" ) $count++;
      }
    
      if( $count >= $form['limitEntriesCount'] ) {
    	  $limit_message = $form['limitEntriesMessage'];
          add_filter('gform_get_form_filter', create_function('', "return '<p class=\"limitmessage\">$limit_message</p>';") );
      }
    
      return $form;
    }
    
    add_filter("gform_pre_render", "count_with_avecs");

    TODO: fix if( $lead['8.1'] == "KYLLÄ" ) to search right field automaticly (This KYLLÄ means Yes and it's the value. It can be easily changed to field to have different count in it...)

    Posted 11 years ago on Monday February 25, 2013 | Permalink
  4. kevinmcgillivray
    Member

    Sakari, did this end up working out for you? I'm trying to do something similar and it looks like your code may be a good starting point. My only question is that it seems like your code above would put a limit on ALL forms. Is the case or does 8.1 only refer to a specific field that is unique across all forms?

    Thanks!

    Posted 11 years ago on Tuesday April 23, 2013 | Permalink