Last active
December 20, 2024 10:19
-
-
Save audrasjb/073ed605e4b47c131c859c6befca80b0 to your computer and use it in GitHub Desktop.
Gravity Forms: Retrieves how much available entries are available for a given form
This file contains hidden or 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 | |
/** | |
* Retrieves how much available entries are available for a given form. | |
* | |
* @param int|false $form_id The ID of the form. | |
*/ | |
function jba_display_available_seats( $form_id = false ) { | |
if ( ! $form_id ) { return; } | |
$form = GFAPI::get_form( $form_id ); | |
if ( rgar( $form, 'limitEntriesCount' ) ) { | |
$count = GFAPI::count_entries( 2 ); | |
$limit = rgar( $form, 'limitEntriesCount' ); | |
return = sprintf( | |
__( 'Available seats: %1$s on %2$s', 'textdomain' ), | |
$limit - $count, | |
$limit | |
); | |
} | |
} | |
?> | |
<!-- Example --> | |
<p><?php echo jba_display_available_seats( 2 ); ?></p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment