Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created June 26, 2025 15:27
Show Gist options
  • Save andrasguseo/a9f6e722bd17eacbf6f093f7329d57a4 to your computer and use it in GitHub Desktop.
Save andrasguseo/a9f6e722bd17eacbf6f093f7329d57a4 to your computer and use it in GitHub Desktop.
ET > Template overrides for the name and email field for RSVPs to not allow changing the values when logging in is required.
<?php
/**
* Block: RSVP
* Form Email
*
* This is a template override that will lock the 'email' field with the email of the user who is logged in,
* if the "Tickets > Settings > General > Require users to log in before they RSVP" is enabled.
* If the setting is disabled, the field content can be changed.
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe/tickets/v2/rsvp/form/fields/email.php
*
* This is a template override for the following file:
* event-tickets/src/views/v2/rsvp/form/fields/email.php
*
* See more documentation about our Blocks Editor templating system.
*
* @link https://evnt.is/1amp Help article for RSVP & Ticket template files.
*
* @since 4.12.3
* @since 5.0.0 Updated the input name used for submitting data.
*
* @version 5.0.0
*/
/**
* Set the default value for the email on the RSVP form.
*
* @param string $email The email value.
* @param Tribe__Tickets__Editor__Template $template The template object.
*
* @since 4.9
*/
$email = apply_filters( 'tribe_tickets_rsvp_form_email', '', $this );
// Check if logging in is required for RSVPs.
$login_required = tribe_get_option( 'ticket-authentication-requirements', false );
$readonly = array_key_exists( 'event-tickets_rsvp', array_flip( $login_required ) ) ? 'readonly' : '';
?>
<div class="tribe-common-b1 tribe-common-b2--min-medium tribe-tickets__form-field tribe-tickets__form-field--required">
<label
class="tribe-tickets__form-field-label"
for="tribe-tickets-rsvp-email-<?php echo esc_attr( $rsvp->ID ); ?>"
>
<?php esc_html_e( 'Email', 'event-tickets' ); ?><span class="screen-reader-text"><?php esc_html_e( 'required', 'event-tickets' ); ?></span>
<span class="tribe-required" aria-hidden="true" role="presentation">*</span>
</label>
<input
type="email"
class="tribe-common-form-control-text__input tribe-tickets__form-field-input tribe-tickets__rsvp-form-field-email"
name="tribe_tickets[<?php echo esc_attr( absint( $rsvp->ID ) ); ?>][attendees][0][email]"
id="tribe-tickets-rsvp-email-<?php echo esc_attr( $rsvp->ID ); ?>"
value="<?php echo esc_attr( $email ); ?>"
required
placeholder="<?php esc_attr_e( '[email protected]', 'event-tickets' ); ?>"
<?php
// Set the field readonly if needed.
echo $readonly;
?>
>
</div>
<?php
/**
* Block: RSVP
* Form Name
*
* This is a template override that will lock the 'name' field with the name of the user who is logged in,
* if the "Tickets > Settings > General > Require users to log in before they RSVP" is enabled.
* If the setting is disabled, the field content can be changed.
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe/tickets/v2/rsvp/form/fields/name.php
*
* This is a template override for the following file:
* event-tickets/src/views/v2/rsvp/form/fields/name.php
*
* See more documentation about our Blocks Editor templating system.
*
* @link https://evnt.is/1amp Help article for RSVP & Ticket template files.
*
* @since 4.12.3
* @since 5.0.0 Updated the input name used for submitting.
*
* @version 5.0.0
*/
/**
* Set the default Full Name for the RSVP form
*
* @param string $name The name value.
* @param Tribe__Tickets__Editor__Template $template The template object.
*
* @since 4.9
*/
$name = apply_filters( 'tribe_tickets_rsvp_form_full_name', '', $this );
// Check if logging in is required for RSVPs.
$login_required = tribe_get_option( 'ticket-authentication-requirements', false );
$readonly = array_key_exists( 'event-tickets_rsvp', array_flip( $login_required ) ) ? 'readonly' : '';
?>
<div class="tribe-common-b1 tribe-common-b2--min-medium tribe-tickets__form-field tribe-tickets__form-field--required">
<label
class="tribe-tickets__form-field-label"
for="tribe-tickets-rsvp-name-<?php echo esc_attr( $rsvp->ID ); ?>"
>
<?php esc_html_e( 'Name', 'event-tickets' ); ?><span class="screen-reader-text"><?php esc_html_e( 'required', 'event-tickets' ); ?></span>
<span class="tribe-required" aria-hidden="true" role="presentation">*</span>
</label>
<input
type="text"
class="tribe-common-form-control-text__input tribe-tickets__form-field-input tribe-tickets__rsvp-form-field-name"
name="tribe_tickets[<?php echo esc_attr( absint( $rsvp->ID ) ); ?>][attendees][0][full_name]"
id="tribe-tickets-rsvp-name-<?php echo esc_attr( $rsvp->ID ); ?>"
value="<?php echo esc_attr( $name ); ?>"
required
placeholder="<?php esc_attr_e( 'Your Name', 'event-tickets' ); ?>"
<?php
// Set the field readonly if needed.
echo $readonly;
?>
>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment