SHARE
TWEET

apply processing only to forms with limited entries

chrishajer Oct 12th, 2011 117 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. add_filter('gform_pre_render', 'show_entries_left');
  3. function show_entries_left($form) {
  4.         // see if this form has a limit set and we need to show how many are left
  5.         if(empty($form['limitEntriesCount'])) {
  6.                 return $form;
  7.         }
  8.         // limit is set; continue processing
  9.         else {
  10.                 // get the number of entries for this form
  11.                 $entry_count = RGFormsModel::get_lead_count($form['id'], "", null, null, null, null);
  12.  
  13.                 // subtract the entry count from the limit to determine how many are left
  14.                 $left =  $form['limitEntriesCount'] - $entry_count;
  15.  
  16.                 // append the number of entries left to the description displayed before the form
  17.                 $form['description'] .= "Hurry! Only <strong>$left</strong> more entries will be accepted.";
  18.  
  19.                 // return the form
  20.                 return $form;
  21.         }
  22. }
  23.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top