if you already enable Gravity form Limit number of entries option. Now you want to show how many entries left of the Gravity form on the post to encourage users to register the event. Then here is the answer to that.
First you need copy and paste the code below into your theme’s functions.php file. ( the original artical link :http://gravitywiz.com/shortcode-display-number-of-entries-left/ )
/**
* Entries Left Shortcode
* http://gravitywiz.com/2012/09/19/shortcode-display-number-of-entries-left/
*/
add_filter( 'gform_shortcode_entries_left', 'gwiz_entries_left_shortcode', 10, 2 );
function gwiz_entries_left_shortcode( $output, $atts ) {
extract( shortcode_atts( array(
'id' => false,
'format' => false // should be 'comma', 'decimal'
), $atts ) );
if( ! $id )
return '';
$form = RGFormsModel::get_form_meta( $id );
if( ! rgar( $form, 'limitEntries' ) || ! rgar( $form, 'limitEntriesCount' ) )
return '';
$entry_count = RGFormsModel::get_lead_count( $form['id'], '', null, null, null, null, 'active' );
$entries_left = rgar( $form, 'limitEntriesCount' ) - $entry_count;
$output = $entries_left;
if( $format ) {
$format = $format == 'decimal' ? '.' : ',';
$output = number_format( $entries_left, 0, false, $format );
}
return $entries_left > 0 ? $output : 0;
}
Then in your WordPress post you can use this short-code to show remaining entries of Gravity forms.
[gravityforms action="entries_left" id="1"]
Result: