How to Display Remaining Entry Limit Number


Would you like to know how to display the remaining entry limit on your form with the Form Locker Addon? This is especially helpful if you’d like to let your visitors know how many entries are left. In this tutorial, we’ll show you how to use PHP to show the remaining entries on the form.

Within the Form Locker Addon, you can choose to limit the number of entries that can be submitted for a form.

After that entry limit is reached, the Form Locker Addon will automatically close your form.


If you’d like to display the number of remaining entries within the embedded form, you can add the code below to your site.

 * Display remaining entry limit.
 * @link
add_action( 'wpforms_frontend_output', function ( $form_data ) {

        if ( empty( $form_data['settings']['form_locker_entry_limit_enable'] ) ) {

        $reference     = ! empty( $form_data['settings']['form_locker_entry_limit'] ) ? (int) $form_data['settings']['form_locker_entry_limit'] : 0;
        $entries_count = wpforms()->entry->get_entries( array( 'form_id' => $form_data['id'] ), true );
        $result        = absint( $reference - $entries_count );

        echo '<p>' . esc_html( $result ) . ' entries left.</p>';

}, 7 );

Once the code is added, the output will display below the form’s title and above the form fields.

Now you can see we're displaying the remaining entry limit on our form

The number displayed will be determined when the form is loaded. As a result, this number may not be accurate by the time the user submits the form.

And that’s all you need to display the remaining entry number on your Form Locker forms. Would you like to display a count of how many form submissions your form has received? Take a look at our tutorial on How to Display Entry Submissions Count for a Specific Form.


Action Reference: wpforms_frontend_output