cliff
8/13/2018 - 11:12 PM

Event Tickets Plus: Disable attendees' ability to modify their attendee information, their RSVP "Going / Not Going" status, and/or their "Do

Event Tickets Plus: Disable attendees' ability to modify their attendee information, their RSVP "Going / Not Going" status, and/or their "Don't list me on the public attendee list" response at yoursite/event/your-single-event/tickets/

<?php
/**
 * Event Tickets Plus: Disable attendees' ability to modify their attendee information, their RSVP
 * "Going / Not Going" status, and/or their "Don't list me on the public attendee list" response
 * at yoursite/event/your-single-event/tickets/
 *
 * @link https://gist.github.com/cliffordp/5bf5a283b2b3ffaf64c119d86613ced0 This snippet.
 */
add_action( 'tribe_tickets_pre_get_template_part', 'cliff_etplus_disable_attendee_able_to_edit_meta', 10, 3 );
function cliff_etplus_disable_attendee_able_to_edit_meta( $slug, $name, $data ) {
	// TODO: !!! CUSTOMIZE THIS !!! Change to an empty array or fully delete it to disable meta editing for all events.
	$event_ids_w_disabled_meta_editing = [
		154,
	];

	if ( 'tickets-plus/orders-edit-meta' !== $slug ) {
		return;
	}

	if (
		! empty( $event_ids_w_disabled_meta_editing )
		&& (
			empty( $data['attendee']['event_id'] )
			|| ! in_array( absint( $data['attendee']['event_id'] ), $event_ids_w_disabled_meta_editing )
		)
	) {
		return;
	}

	// TODO: !!! Read these comments because you may want to alter the behavior !!!
	?>
    <script>
		jQuery( document ).ready( function () {
			// Disallow changes to existing attendee meta information
			jQuery( 'form .ticket-meta' ).prop( 'disabled', true );
			// Disallow changes to RSVP "Going / Not Going"
			jQuery( 'form select' ).prop( 'disabled', true );
			// Disallow changes to "Don't list me on the public attendee list" checkbox
			jQuery( 'form input' ).prop( 'disabled', true );
			// Remove the submit button
            // !!! Do not do this if you modify the code above to enable modifying some but not all data !!!
			jQuery( 'form .tribe-submit-tickets-form' ).remove();
		} );
    </script>
	<?php
}