### [How to Display Remaining Entry Limit Number](https://wpforms.com/developers/how-to-display-remaining-entry-limit-number/)

**Published:** October 14, 2019
**Author:** Editorial Team

**Excerpt:** This tutorial will walk you through how to display the remaining entry limit on your form when using the Form Locker addon. 

**Content:**

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 qddon](https://wpforms.com/docs/how-to-install-and-use-the-form-locker-addon-in-wpforms/ "How to Install and Use the Form Locker Addon in WPForms"), you can choose to [limit the number of entries that can be submitted for a form](https://wpforms.com/docs/how-to-install-and-use-the-form-locker-addon-in-wpforms/#limit-entries "How to limit entries with the Form Locker Addon").

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

For our tutorial, we want our visitors to see how many entries are left before the form will close.

## Creating your form

To begin, we’ll create a new form and add our fields. For the purpose of this tutorial we’re only going to collect the **Name** and **Email Address** for an entry.

If you need any help in creating your form, [please see this documentation](https://wpforms.com/docs/creating-first-form/ "How to Create Your First Form").

![](https://wpforms.com/wp-content/uploads/2019/10/wpforms-creating-the-form-entry-limit.jpg)

## Enabling the entry limit

Next, we’ll enable the entry limit on the form by clicking the **Settings** tab and then selecting the **Form Locker** tab. Under the **Entry Limits & Restrictions**, we’re going to slide the toggle to **Enable total entry limit**, set the **Limit** amount, and the **Message** that will display when the form is closed.

![enable the form locker entry limit](https://wpforms.com/wp-content/uploads/2019/10/wpforms-enable-form-locker.jpg)

## Display remaining entries

Finally, we’ll need to add this snippet to our site.

If you’re not sure how to add snippets to your site, [please review this tutorial.](https://wpforms.com/developers/how-to-add-custom-php-or-javascript-for-wpforms/ "How to Add Custom PHP or JavaScript for WPForms")

```

/**
 * Display remaining entry limit.
 *
 * @link https://wpforms.com/developers/how-to-display-remaining-entry-limit-number/
 */

function wpf_dev_remaining_entries( $form_data ) {
 
    // Optional, you can limit to specific forms. Below, we restrict output to
    // form #1899.
    if ( absint( $form_data[ 'id' ] ) !== 1899 ) {
        return;
    }
 
    if ( empty( $form_data[ 'settings' ][ 'form_locker_entry_limit_enable' ] ) ) {
        return;
    }
 
    $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 '' . esc_html( $result ) . __( ' entries remaining', 'text-domain' ) . '';
 
}
 
add_action( 'wpforms_frontend_output', 'wpf_dev_remaining_entries', 10, 1 );
```

You’ll need to update the form ID in the above snippet to match your own form ID. If you need assistance in finding your form ID, [please check out this tutorial](https://wpforms.com/developers/how-to-locate-form-id-and-field-id/ "How to Locate Form ID and Field ID").

Once the code is added, the entry limit 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](https://wpforms.com/wp-content/uploads/2019/10/wpforms-display-entry-limit-number.jpg)

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](https://wpforms.com/developers/display-entry-submissions-count-for-a-specific-form/ "How to Display Entry Submissions Count for a Specific Form").

## Reference Action

[wpforms\_frontend\_output](https://wpforms.com/developers/wpforms_frontend_output/ "Using the wpforms_frontend_output action")

**Categories:** Extending

**Tags:** Form Locker Addon, PHP

---

