Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the logged-out ticket registration flow #1399

Merged
merged 3 commits into from
Oct 18, 2024
Merged
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
34 changes: 26 additions & 8 deletions public_html/wp-content/plugins/camptix/addons/require-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ class CampTix_Require_Login extends CampTix_Addon {
* Register hook callbacks
*/
public function __construct() {
// Registration Information front-end screen
add_filter( 'camptix_register_button_classes', array( $this, 'hide_register_form_elements' ) );
add_filter( 'camptix_coupon_link_classes', array( $this, 'hide_register_form_elements' ) );
add_filter( 'camptix_quantity_row_classes', array( $this, 'hide_register_form_elements' ) );
// Registration Information front-end screen.
add_action( 'camptix_notices', array( $this, 'ticket_form_message' ), 8 );
add_filter( 'camptix_ask_questions', array( $this, 'hide_additional_attendee_questions_during_checkout' ), 10, 5 );
add_filter( 'camptix_form_register_complete_attendee_object', array( $this, 'add_username_to_attendee_object' ), 10, 3 );
Expand Down Expand Up @@ -59,16 +56,37 @@ public function __construct() {
public function block_unauthenticated_actions() {
/** @var $camptix CampTix_Plugin */
global $camptix;
// Continue normal request, this is not a tickets page.
if ( ! isset( $_REQUEST['tix_action'] ) ) {
return;
}

Comment on lines +59 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the logic a little here so we don't need to keep checking for this being set.

// Bypass for payment webhook notifications.
if ( isset( $_REQUEST['tix_action'] ) && isset( $_REQUEST['tix_payment_token'] ) && $_REQUEST['tix_action'] == 'payment_notify' ) {
if ( 'payment_notify' === $_REQUEST['tix_action'] && isset( $_REQUEST['tix_payment_token'] ) ) {
return;
}

// Bypass for coupon validation- the `tix_coupon_submit` value is set when "Apply Coupon" button is clicked.
if ( 'attendee_info' === $_REQUEST['tix_action'] && isset( $_REQUEST['tix_coupon'], $_REQUEST['tix_coupon_submit'] ) ) {
return;
}

if ( ! is_user_logged_in() && isset( $_REQUEST['tix_action'] ) ) {
wp_safe_redirect( wp_login_url( add_query_arg( $_REQUEST, $camptix->get_tickets_url() ) ) );
if ( ! is_user_logged_in() ) {
$args = array();
// If this was a registration, pass through the selected tickets and coupon.
if ( 'attendee_info' === $_REQUEST['tix_action'] && isset( $_REQUEST['tix_tickets_selected'] ) ) {
$args['tix_action'] = $_REQUEST['tix_action'];
$args['tix_tickets_selected'] = $_REQUEST['tix_tickets_selected'];
if ( isset( $_REQUEST['tix_coupon'] ) ) {
$args['tix_coupon'] = $_REQUEST['tix_coupon'];
}
}

$tickets_url = add_query_arg( $args, $camptix->get_tickets_url() );

wp_safe_redirect( add_query_arg( 'wcname', get_bloginfo( 'name' ), wp_login_url( $tickets_url ) ) );
exit();
}

}

/**
Expand Down
Loading