Skip to content

Commit

Permalink
CampTix: Improve the logged-out ticket registration flow (#1399)
Browse files Browse the repository at this point in the history
* Restore the full form UI for logged-out users on the ticket purchase screen
* Pass the WordCamp name in query string to use on the login form
* Bypass the login check when applying a coupon
* Pass through the ticket parameters via the login redirect link

Logged-out users will be able to apply coupon & select tickets, and once they click Register, will be redirected to log in or register for wordpress.org. Once logged in, they'll redirect back to the checkout flow, with the coupon applied and tickets selected.

Fixes #1397

---------

Co-authored-by: Kelly Dwan <ryelle@users.noreply.github.com>
  • Loading branch information
tellyworth and ryelle authored Oct 18, 2024
1 parent 74963de commit c0ab1d5
Showing 1 changed file with 26 additions and 8 deletions.
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;
}

// 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

0 comments on commit c0ab1d5

Please sign in to comment.