Created
September 13, 2012 00:18
-
-
Save spivurno/3710935 to your computer and use it in GitHub Desktop.
Gravit Wiz // Display Entries Left Based on Entry Limit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display Entries Left Based on Entry Limit | |
* http://gravitywiz.com/2012/04/25/display-number-of-entries-left-based-on-entry-limit/ | |
*/ | |
// update the "4" to the ID of your form | |
add_action('gform_pre_render_4', 'gform_display_limit'); | |
function gform_display_limit($form) { | |
// put the %s wherever you want the number of entries to display in your message | |
$entries_left_message = 'Only %s positions left!'; | |
/* You do not need to edit below this line */ | |
$entry_count = RGFormsModel::get_lead_count($form['id'], ''); | |
$entries_left = $form["limitEntriesCount"] - $entry_count; | |
if($entries_left > 0) { | |
$form['description'] .= sprintf('<div class="entries-left">' . $entries_left_message . '</div>', $entries_left); | |
} | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-display-number-of-entries-left-based-on-entry-limit.php