chrishajer

show number of entries left

Oct 3rd, 2011
381
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // http://www.gravityhelp.com/forums/topic/display-number-of-form-entries-left-per-form
  2. // change 3 here to your form ID
  3. add_filter('gform_pre_render_3', 'show_entries_left');
  4. function show_entries_left($form) {
  5.     // get the number of entries for this form
  6.     $entry_count = RGFormsModel::get_lead_count($form['id'], "", null, null, null, null);
  7.  
  8.     // subtract the entry count from the limit to determine how many are left
  9.     $left =  $form['limitEntriesCount'] - $entry_count;
  10.  
  11.     // append the number of entries left to the description displayed before the form
  12.     $form['description'] .= "Hurry! Only <strong>$left</strong> more entries will be accepted.";
  13.  
  14.     // return the form
  15.     return $form;
  16. }
  17.  
  18.  
RAW Paste Data