💡 Note: This solution only works with RSVPs. It does not work with tickets!

Attendee Information Collection is a feature of Event Tickets Plus, that allows you to require information from users registering or purchasing tickets for your events. It is possible to set up a required field, so a registration cannot be done or a ticket cannot be purchased if that field is not filled with information for all of the ticket holders.

There might be scenarios, however, where the information would only be required from the main guest and would be optional for the other guests. While this cannot be done out of the box, it is possible with a template override.

There are different field types you can use to collect information, like a text field, a checkbox, or a date, among others. A template override will be needed for each field type where you want this functionality. In this example, we will walk you through the process for the text field. The approach is the same, or very similar for all other field types.

Create the template override

The templates for the attendee fields can be found in this folder:

wp-content\plugins\event-tickets-plus\src\views\v2\components\meta\

Since we are creating an override for the text field, we need to grab the text.php file, and place a copy of it in the following folder:

wp-content/themes/[your-theme]/tribe/tickets-plus/v2/components/meta/text.php

The folder structure likely doesn’t exist in your child theme folder, so you will need to create it.

This copied text.php file is the one we will be working on.

Detour: The other fields

In this example, we are using the text field, but the process would be very similar or might be even the same for the other fields. Here’s a list of the other fields and the files, which would need to receive a template override.

Texttext.php
Radioradio.php
Checkboxcheckbox.php
Dropdownselect.php
Emailemail.php
Telephonetelephone.php
URLurl.php
Birth Date birth.php
Datedatetime.php

Add the code

The code goes at the top of the file between the opening and closing php tags.

The piece of code we are going to add does the following:

  1. Checks which field is being rendered. (Line 2)
  2. Checks if the field is being rendered for the main guest. (Line 4)
  3. Sets the field as required. (Line 6)
  4. Adds additional text to the description. (Line 8)
  5. Hides the field for all other guests. (Line 9-15)
// If the name of the text is "Phone number", then the slug is "phone-number".
if ( $field->slug == 'phone-number' ) {
    // Limit to main guest
    if ( $attendee_id === 0 ) {
        // Set it required.
        $required = true;
        // Add to the description
        $description .= " Required for main attendee.";
    } else {
        // Do this for other guests
        // Hide the field.
        // Remove 'return' or the whole 'else' branch, 
        // if the field should be shown for other guests, but not required.
        return;
    }
}

On line 2, we are checking the slug of the field that is being rendered. The slug will be the label of the field with lowercase letters, special characters removed, and the space character changed to a minus (-) character. For example, if your field name would be “Date of Birth:”, then the slug would become “date-of-birth”.

On line 4 we are checking if the field is being rendered for the main guest. You can turn this around as well if you want to make a field required for all guests except the main one. Then you will need to use

if ( $attendee_id != 0 ) {

On line 8 we are adding some extra text to the description. This can be a nice touch and makes it clear what needs to be done. This is optional though.

If we want to hide the specific field for all other guests, then we can simply do a return; in the else branch; this way nothing will be rendered. If you still want to show the field to other guests but not make it required, then you can remove the full else branch.

The rest of the template is unchanged.

And that is it!

This example was done on the text field. It is possible to do this on other fields as well, you just need to override the right file.

The full file

Here is the full code of the file for reference:

<?php
/**
 * This template renders the Text or Textarea field.
 *
 * Override this template in your own theme by creating a file at:
 * [your-theme]/tribe/tickets-plus/v2/components/meta/text.php
 *
 * @link    https://evnt.is/1amp See more documentation about our views templating system.
 *
 * @since 5.0.0
 * @since 5.1.0 Added support for div HTML attributes.
 * @since 5.1.1 Added support for placeholders.
 * @since 5.2.9 Added support for description.
 *
 * @version 5.2.9
 *
 * @var string $field_name The meta field name.
 * @var string $field_id The meta field id.
 * @var bool   $required A bool indicating if the meta field is required or not.
 * @var string|int $attendee_id The attendee ID, to build the ID/name.
 * @var array $classes Array containing the CSS classes for the field.
 * @var array $attributes Array containing the HTML attributes for the field.
 * @var string $placeholder The field placeholder text.
 * @var bool $disabled Field is disabled or not.
 * @var string $value Value for field.
 * @var Tribe__Tickets__Ticket_Object $ticket The ticket object.
 * @var Tribe__Tickets_Plus__Meta__Field__Text $field.
 * @var string $description A user-defined description for meta field.
 *
 * @see Tribe__Tickets_Plus__Meta__Field__Text
 */

$multiline = Tribe__Utils__Array::get( $field, [ 'extra', 'multiline' ], null );

// The name of the text field has to be "Phone number".
if ( $field->slug == 'phone-number' ) {
	// Limit to main guest
	if ( $attendee_id === 0 ) {
		// Set it required.
		$required = true;
		// Add to the description
		$description .= " Required for main attendee.";
	} else {
		// Hide the field.
		return;
		// Remove 'return' above if the field should be shown for other guests, but not required.
	}
}
?>

<div
	<?php tribe_classes( $classes ); ?>
	<?php tribe_attributes( $attributes ); ?>
>
	<label
		class="tribe-tickets__form-field-label"
		for="<?php echo esc_attr( $field_id ); ?>"
	><?php echo wp_kses_post( $field->label ); ?><?php tribe_required_label( $required ); ?></label>
	<div class="tribe-tickets__form-field-input-wrapper">
		<?php if ( $multiline ) : ?>
			<textarea
				id="<?php echo esc_attr( $field_id ); ?>"
				class="tribe-common-form-control-text__input tribe-tickets__form-field-input"
				name="<?php echo esc_attr( $field_name ); ?>"
				placeholder="<?php echo esc_attr( $placeholder ); ?>"
				<?php tribe_required( $required ); ?>
				<?php tribe_disabled( $disabled ); ?>
			><?php echo esc_textarea( $value ); ?></textarea>
		<?php else : ?>
			<input
				type="text"
				id="<?php echo esc_attr( $field_id ); ?>"
				class="tribe-common-form-control-text__input tribe-tickets__form-field-input"
				name="<?php echo esc_attr( $field_name ); ?>"
				value="<?php echo esc_attr( $value ); ?>"
				placeholder="<?php echo esc_attr( $placeholder ); ?>"
				<?php tribe_required( $required ); ?>
				<?php tribe_disabled( $disabled ); ?>
			/>
		<?php endif; ?>
		<?php if ( ! empty( $description ) ) : ?>
			<div class="tribe-common-b3 tribe-tickets__form-field-description">
				<?php echo wp_kses_post( $description ); ?>
			</div>
		<?php endif; ?>
	</div>
</div>