> For the complete documentation index, see [llms.txt](https://kb.craftformswp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.craftformswp.com/documentation/form-building/create-form/blocks/generated-reference-numbers.md).

# Generated Reference Numbers

A hidden field can make a number when the form is sent: a membership number like **MEM-2026-0001**, a ticket or claim reference like **K7QM-3XRW**, or an order-style number like **QT-202611-0042**. The number is made on your server, is never given twice in the same form, and can go in the thank-you message, emails, PDFs and the new user's profile like any other answer.

![A thank-you message showing the member number MEM-2026-0003](https://97821998-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM2yV1foUgoGHBC66VBDw%2Fuploads%2FJzcwbDOA6ePeasECHJLD%2Fgenerated-reference-numbers--confirmation.jpg?alt=media)

### What you need

* **CraftForms (free)**, version 2.3 or later.
* To save the number on a WordPress user account, the **User Registration** action (PRO). See [Account Forms](/documentation/form-building/create-form/form-settings-post-context/submit-actions/account-forms.md).

### Add a generated number

1. Open your form in the editor (**CraftForms → Forms → Edit**).
2. Add a **Text Input Field** and set its **Input Type** to **Hidden**.
3. Give it a **Label** ("Member number") and a **Field Name** (`member_number`).
4. Turn on **Generate a number when the form is sent**. The **Number format** is filled in with `MEM-{YYYY}-{0001}`.
5. Change the format if you like (see below), then save the form.

![The hidden field's settings with Generate a number when the form is sent turned on](https://97821998-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM2yV1foUgoGHBC66VBDw%2Fuploads%2F37UJ7IIT41ZllpcBSlGW%2Fgenerated-reference-numbers--generate-setting.jpg?alt=media)

### Number formats

Write the format as plain text with these parts in braces:

| Part                          | Gives                                                                                                                                 | Example                   |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `{0001}`                      | A counter: 1, 2, 3… with as many digits as you write (`{01}` = 01, `{00001}` = 00001). It keeps growing past them (9999, then 10000). | `MEM-{0001}` → MEM-0001   |
| `{YYYY}` `{YY}` `{MM}` `{DD}` | Today's year, short year, month and day, in your site's time zone.                                                                    | `{YYYY}{MM}` → 202611     |
| `{XXXX}`                      | Random capital letters and digits. Look-alikes (0, O, 1, I, L) are left out, so the code is easy to read out and type.                | `{XXXX}` → K7QM           |
| `{####}`                      | Random digits.                                                                                                                        | `{######}` → 482019       |
| `-` inside braces             | A dash in a random part.                                                                                                              | `{XXXX-XXXX}` → K7QM-3XRW |

Examples:

| Format                | First numbers                                              |
| --------------------- | ---------------------------------------------------------- |
| `MEM-{YYYY}-{0001}`   | MEM-2026-0001, MEM-2026-0002… and MEM-2027-0001 in January |
| `QT-{YYYY}{MM}-{001}` | QT-202611-001… starting again at 001 each month            |
| `{XXXX-XXXX}`         | K7QM-3XRW, 9HTD-PZ4E…                                      |
| `T-{####}`            | T-4820, T-0193…                                            |

**When the counter starts again:** each counter belongs to the format with the date filled in. With `{YYYY}` in the format it starts again at 1 every year, with `{MM}` every month. Without a date part it never starts again.

### Show and use the number

Use the field like any answer, with its **Field Name**:

* **Thank-you message**: `Your member number is {{field.member_number}}.` in a [Confirmation](/documentation/form-building/create-form/blocks/confirmation.md) block.
* **Emails**: `{{field.member_number}}` in a **Send Email** action, or in an email template.
* **PDFs**: `{{field.member_number}}` in a PDF template, for a membership card or a ticket. Add a QR code or barcode of it with the [QR Code / Barcode](/documentation/pdf-templates/create-pdf-template/qr-code-barcode.md) block.
* **Submissions**: the number is saved with the submission and shows in **CraftForms → Submissions**.
* **User accounts** (PRO): in **User Registration**, map the field to **Custom User Meta** with a meta key such as `member_number`. The number is then saved on the new user's profile.

### Good to know

* **Never repeated in the form.** Every number given is kept with the form, and a clash makes a new one. Two forms sent at the same moment get different numbers. Two different forms (or two fields) can give the same number, so use a different prefix in each.
* **Made after the checks.** The number is made once the form has passed every check (required fields, spam protection, an account that already exists), just before the submit actions run. A refused form doesn't use a number up, so a counter has no gaps from errors.
* **Made on the server.** Whatever is in the field on the page is replaced, so a visitor can't choose their own number.
* **Renewals keep the number.** When **User Registration** updates the account of a member who is logged in, a generated number already on the profile is kept; a member is never renumbered. See [If the account already exists](/documentation/form-building/create-form/form-settings-post-context/submit-actions/account-forms.md#if-the-account-already-exists).
* A format with no braces gives the same text every time, and only once: after that the form can't make a new one. Always include a counter or a random part.
* Numbers are up to 100 characters.
