Event Booking & Ticket Tracking with Fluent Forms & ACF


We are going to be creating a booking form that dynamically populates the price of the ticket from a custom post type and then keeps track of how many tickets are available. It will stop people booking more than the available tickets and give them the appropriate error.



1. Create a new post type

I am using ACF Extended to create my post types, but CPTUI plugin would also work.

image 8

2. Create Event Price field

We need to create a number field to store the price of the event.

Set the field_name to event_price

image 7

3. Create Event Tickets field

We need to create a number field to store the number of tickets for the event.

Set the field_name to event_tickets

image 6

4. Add a new event and populate fields

image 5

5. Create a new form

Add two number fields: event_price and event_tickets

The fields need to have the name attributes set under the advanced tab as event_price and event_tickets respectively.

image 4

6. Post ID field

Add a field to store the post ID of the event.

Make sure you set the default value to {embed_post.ID}

image 3

7. Create your Event template

I am using GeneratePress & GenerateBlocks in this example. However you can use whatever builder or theme you like.

The only important thing is that you add the Fluent Form you just created somewhere inside the template, using the supported Gutenberg block or shortcode method.

image 2

The Code

Copy and paste the code below into your functions.php or code snippet plugin.

Make sure you update the Form ID's to your form



// Adding Event Price to Form
add_filter("fluentform_rendering_field_data_input_number",function ($data, $form) {
    if ($form->id != 3) { // Replace with your Form ID
        return $data;

    // check if the name attriibute of the form field is 'numeric_price'

    if (\FluentForm\Framework\Helpers\ArrayHelper::get($data,"attributes.name") == "event_price") {
        //Get the custom field value
        $form_price = get_field("event_price");

        //Build the values for the array to be return to the form
        $custom = ["value" => $form_price, "readonly" => "true"];
        $data["attributes"] = array_merge($data["attributes"], $custom);

        return $data;
    } else {
        return $data;

// Validating there are tickets available

add_filter("fluentform_validate_input_item_input_number",function ($errorMessage, $field, $formData, $fields, $form) {
    if ($form->id != 3) { // Replace with your Form ID
        return $default;

    if ($field["raw"]["attributes"]["name"] === "event_tickets") {
        $event_price = get_field("event_price", $formData["post_id"]);
        $tickets = get_field("event_tickets", $formData["post_id"]);

        $form_price = $formData["event_price"];
        $form_tickets = $formData["event_tickets"];

        if ($event_price != $form_price) {
            $errorMessage = ["Price has changed"];

        $tickets_left = $tickets - $form_tickets;
        if ($tickets_left < 0) {
            $errorMessage = [
                "Sorry there are only " . $tickets . " ticket(s) left.",
        if ($tickets == 0) {
            $errorMessage = ["We are sorry, there are no tickets left"];

        return $errorMessage;

    return $errorMessage;


function tct_event_submission_confirmation($entryId, $formData, $form)
    if ($form->id != 3) { // Replace with your Form ID

    $tickets = get_field("event_tickets", $formData["post_id"]);
    $form_tickets = $formData["event_tickets"];
    $new_tickets = $tickets - $form_tickets;

    update_field("event_tickets", $new_tickets, $formData["post_id"]);

Final Outcome

🎉 Thats it!

Once you have set everything up, it will give you an error if trying to book more tickets than available, or if the are no tickets left.