Tribe__Tickets__RSVP::render_rsvp_step( int $ticket_id, null|string $step = null )
Handle RSVP processing for the RSVP forms.
Contents
Parameters
- $ticket_id
-
(int) (Required) The ticket ID.
- $step
-
(null|string) (Optional) Which step to render.
Default value: null
Return
(string) The step template HTML.
Source
File: src/Tribe/RSVP.php
public function render_rsvp_step( $ticket_id, $step = null ) {
// No ticket.
if ( 0 === $ticket_id ) {
return '';
}
$post_id = (int) get_post_meta( $ticket_id, $this->get_event_key(), true );
// No post found, something went wrong.
if ( 0 === $post_id ) {
return '';
}
/** @var \Tribe__Tickets__Editor__Blocks__Rsvp $blocks_rsvp */
$blocks_rsvp = tribe( 'tickets.editor.blocks.rsvp' );
/** @var \Tribe__Tickets__Editor__Template $template */
$template = tribe( 'tickets.editor.template' );
$ticket = $this->get_ticket( $post_id, $ticket_id );
// No ticket found.
if ( null === $ticket ) {
return '';
}
// Set required template globals.
$args = [
'rsvp_id' => $ticket_id,
'post_id' => $post_id,
'rsvp' => $ticket,
'step' => $step,
'must_login' => ! is_user_logged_in() && $this->login_required(),
'login_url' => self::get_login_url( $post_id ),
'threshold' => $blocks_rsvp->get_threshold( $post_id ),
];
/**
* Allow filtering of the template arguments used prior to processing.
*
* @since5.0.0
*
* @param array $args {
* The list of step template arguments.
*
* @type int $rsvp_id The RSVP ticket ID.
* @type int $post_id The ticket ID.
* @type Tribe__Tickets__Ticket_Object $rsvp The RSVP ticket object.
* @type null|string $step Which step being rendered.
* @type boolean $must_login Whether login is required to register.
* @type string $login_url The site login URL.
* @type int $threshold The RSVP ticket threshold.
* }
*/
$args = apply_filters( 'tribe_tickets_rsvp_render_step_template_args_pre_process', $args );
$args['process_result'] = $this->process_rsvp_step( $args );
/**
* Allow filtering of the template arguments used.
*
* @since 4.12.3
*
* @param array $args {
* The list of step template arguments.
*
* @type int $rsvp_id The RSVP ticket ID.
* @type int $post_id The ticket ID.
* @type Tribe__Tickets__Ticket_Object $rsvp The RSVP ticket object.
* @type null|string $step Which step being rendered.
* @type boolean $must_login Whether login is required to register.
* @type string $login_url The site login URL.
* @type int $threshold The RSVP ticket threshold.
* @type array $process_result The processing result.
* }
*/
$args = apply_filters( 'tribe_tickets_rsvp_render_step_template_args', $args );
// Return the process result for opt-in.
if ( false === $args['process_result']['success'] ) {
return $args['process_result'];
}
$args['opt_in_checked'] = false;
$args['opt_in_attendee_ids'] = '';
$args['opt_in_nonce'] = '';
$args['is_going'] = null;
if ( ! empty( $args['process_result']['opt_in_args'] ) ) {
// Refresh ticket.
$args['rsvp'] = $this->get_ticket( $post_id, $ticket_id );
$args['is_going'] = $args['process_result']['opt_in_args']['is_going'];
$args['opt_in_checked'] = $args['process_result']['opt_in_args']['checked'];
$args['opt_in_attendee_ids'] = $args['process_result']['opt_in_args']['attendee_ids'];
$args['opt_in_nonce'] = $args['process_result']['opt_in_args']['opt_in_nonce'];
}
// Check to see if attendees list is being hidden or not.
if ( class_exists( 'Tribe__Tickets_Plus__Attendees_List' ) ) {
// Handle Event Tickets Plus compatible logic.
$hide_attendee_list_optout = Tribe__Tickets_Plus__Attendees_List::is_hidden_on( $post_id );
} else {
// Handle Event Tickets logic.
$hide_attendee_list_optout = \Tribe\Tickets\Events\Attendees_List::is_hidden_on( $post_id );
}
/**
* Allow filtering of whether to show the opt-in option for attendees.
*
* @since 4.5.2
* @since5.0.0 Added $post_id and $ticket_id parameters.
*
* @param bool $hide_attendee_list_optout Whether to hide attendees list opt-out.
* @param int $post_id The post ID that the ticket belongs to.
* @param int $ticket_id The ticket ID.
*/
$hide_attendee_list_optout = apply_filters( 'tribe_tickets_hide_attendees_list_optout', $hide_attendee_list_optout, $post_id, $ticket_id );
if ( false === $args['is_going'] ) {
$hide_attendee_list_optout = true;
}
$args['opt_in_toggle_hidden'] = $hide_attendee_list_optout;
// Add the rendering attributes into global context.
$template->add_template_globals( $args );
$html = $template->template( 'v2/components/loader/loader', [ 'classes' => [] ], false );
$html .= $template->template( 'v2/rsvp/content', $args, false );
return $html;
}
Changelog
| Version | Description |
|---|---|
| 5.5.10 | Added going to the $args variable. |
| 4.12.3 | Introduced. |