Attendee Questions

This tutorial requires 1.11.0 which at the time of writing is due to be released in the coming weeks.

‘Attendee Questions’ means form fields that are replicated on your booking form – one for each ticket selected in the booking. So if your bookings typically involve more than one ticket, this allows you, for example, to collect the names and e-mail address of those attending, or perhaps dietary requirements.

In this example there are two ‘attendee question’ fields: name and e-mail. And these appear twice: once for the selected standard ticket and once for the selected student ticket.

There is no UI for adding attendee questions; it is all done through the form API. Additionally, Event Organiser doesn’t do anything, by default, with the collected data, this tutorial however will show you how to include this data in the ticket CSV export and the bookings admin page.

As with all snippets posted on this site, they should work in your theme’s functions.php but it is recommended you create a dedicated ‘site utility plugin’. See more details on this page: Where should I put code from the tutorials?.

Adding the questions

First, here’s the the snippet that adds the attendee questions in its entirety:

It’s strongly recommended to make sure your IDs are unique by prepending your own initials, or those of the project your are working on.

Take a note of the IDs you decide above as we’ll be using them later. Other optional properties include:

label – The label for this field

required – Whether this field must be completed

options – (for select, radio, checkbox fields) An array of the options presented to the user. The key is what is stored, and the value is what is displayed on the form

The second part simply adds the ‘Attendee Question’ element (if it isn’t already present) and adds our form fields beneath it. This allows the plug-in to encapsulate our attendee questions and repeat them for each ticket. The only noteworthy part is the ticket label:

The label is assigned to each set of attendee questions, and {{{ticketname}}} is replaced by the name of the associated ticket. This helps the bookee associate each section of questions which a particular ticket type.

The $column is the column ID of the cell. When it is is equal to either of the three columns we added in the previous part we set the content of the cell. To retrieve ticket meta data we use the following:

Adding columns to the tickets admin table

To add the collected data to the ticket table in the bookings admin page, first use the eventorganiser_booking_tickets_table filter to insert an extra column(s). This should be given a unique identifier to help identify it later. Below, we’ve added a ‘name’ column which we will use to display the first and last name of the ticket holder

Next we’ll use the eventorganiser_booking_tickets_table_column filter to render the content of each cell in our column. Recall the meta key of the data is _eo_booking_meta_{question-id} where {question-id} in this case is attendee-name.

Once we’ve retrieved the name array (first and last name) we’ll use implode to print it: