Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions public_html/wp-content/plugins/camptix/addons/require-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,45 @@ public function ticket_form_message() {
) );
}

// Remind the logged in user about their tickets.
if ( is_user_logged_in() && ! $this->user_is_editing_ticket() && empty( $_REQUEST['tix_action'] ) ) {
$user_tickets = $this->get_tickets_of_user( wp_get_current_user() );

$ticket_links = [];
foreach ( $user_tickets as $ticket ) {
$ticket_link = sprintf(
'%s (%s). %s.', // "Name (Ticket Type). Edit.".
esc_html( $camptix->format_name_string( "%first% %last%", $ticket->tix_first_name, $ticket->tix_last_name ) ),
esc_html( get_the_title( $ticket->tix_ticket_id ) ),
sprintf(
'<a href="%s">%s</a>',
esc_url( $camptix->get_edit_attendee_link( $ticket->ID, $ticket->tix_edit_token ) ),
__( 'Edit information', 'wordcamporg' )
),
);

if ( $this->get_unconfirmed_tickets_purchased_with( $ticket ) ) {
$ticket_link .= sprintf(
'<ul><li>%s</li></ul>',
sprintf(
__( 'One or more tickets are unconfirmed. <a href="%s">View tickets</a>.', 'wordcamporg' ),
esc_url( $camptix->get_access_tickets_link( $ticket->tix_access_token ) )
)
);
}

$ticket_links[] = $ticket_link;
}

if ( $ticket_links ) {
$camptix->info( apply_filters(
'camptix_require_login_your_tickets_message',
'<p>' . __( 'The following tickets are assigned to you:', 'wordcamporg' ) . '</p>' .
'<ul><li>' . implode( '</li><li>', $ticket_links ) . '</li></ul>'
) );
}
}

// Inform a user registering multiple attendees that other attendees will enter their own info
if ( isset( $_REQUEST['tix_action'], $_REQUEST['tix_tickets_selected'] ) ) {
if ( 'attendee_info' == $_REQUEST['tix_action'] && $this->registering_multiple_attendees( $_REQUEST['tix_tickets_selected'] ) ) {
Expand Down Expand Up @@ -998,6 +1037,67 @@ protected function get_ticket_of_user( WP_User $user ) {

return $ticket ? reset( $ticket ) : false;
}

/**
* Retrieve any tickets associated with the given user.
*
* @param WP_User $user The user object for whom to retrieve the tickets.
* @return array An array of ticket post objects.
*/
protected function get_tickets_of_user( WP_User $user ) {
if ( empty( $user->user_login ) ) {
return [];
}

return get_posts( array(
'posts_per_page' => -1,
'post_type' => 'tix_attendee',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'tix_username',
'value' => $user->user_login,
),
'relation' => 'OR',
array(
'key' => 'tix_email',
'value' => $user->user_email,
),
),
) );
}

/**
* Retrieve any unconfirmed tickets associated with the given ticket.
*
* @param WP_Post $ticket The ticket post object.
* @return array An array of unconfirmed ticket post objects.
*/
protected function get_unconfirmed_tickets_purchased_with( WP_Post $ticket ) {
$unconfirmed_tickets = get_posts( array(
'posts_per_page' => -1,
'post_type' => 'tix_attendee',
'post_status' => 'publish',
'post_not_in' => array( $ticket->ID ),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'tix_payment_token',
'value' => $ticket->tix_payment_token,
),
array(
'key' => 'tix_username',
'value' => self::UNCONFIRMED_USERNAME,
),
array(
'key' => 'tix_receipt_email',
'value' => $ticket->tix_email, // May differ from the user email.
),
),
) );

return $unconfirmed_tickets;
}
} // CampTix_Require_Login

camptix_register_addon( 'CampTix_Require_Login' );
7 changes: 6 additions & 1 deletion public_html/wp-content/plugins/camptix/camptix.php
Original file line number Diff line number Diff line change
Expand Up @@ -8173,7 +8173,12 @@ function do_notices() {

$printed = array();
$allowed_html = array_merge(
array( 'p' => array( 'id' => true ) ),
array(
'p' => array( 'id' => true ),
'ul' => true,
'ol' => true,
'li' => true,
),
wp_kses_allowed_html( 'data' )
);

Expand Down
Loading