diff --git a/addons/require-login.php b/c:/xampp/htdocs/daytonwp/test/wp-content/plugins/camptix/addons/require-login.php index 93c04f9..4cf7ef7 100644 --- a/addons/require-login.php +++ b/c:/xampp/htdocs/daytonwp/test/wp-content/plugins/camptix/addons/require-login.php @@ -11,6 +11,16 @@ class CampTix_Require_Login extends CampTix_Addon { public function camptix_init() { add_action( 'template_redirect', array( $this, 'block_unauthenticated_actions' ), 8 ); // before CampTix_Plugin->template_redirect() add_filter( 'tix_action_login', array( $this, 'login' ) ); + add_action( 'camptix_notices', array( $this, 'ticket_form_message' ), 8 ); + add_action( 'camptix_attendee_form_additional_info', array( $this, 'get_attendee_form_username_field' ), 10, 3 ); + add_filter( 'camptix_form_register_complete_attendee_object', array( $this, 'add_username_to_attendee_object' ), 10, 2 ); + add_action( 'camptix_checkout_update_post_meta', array( $this, 'save_checkout_unsername_meta' ), 10, 2 ); + add_filter( 'camptix_save_attendee_post_add_search_meta', array( $this, 'get_attendee_search_meta' ) ); + add_filter( 'camptix_attendee_report_extra_columns', array( $this, 'get_attendee_report_extra_columns' ) ); + add_filter( 'camptix_attendee_report_column_value_username', array( $this, 'get_attendee_username_meta' ), 10, 2 ); + add_filter( 'camptix_metabox_attendee_info_additional_rows', array( $this, 'get_attendee_metabox_rows' ), 10, 2 ); + add_action( 'camptix_form_edit_attendee_update_post_meta', array( $this, 'update_attendee_post_meta' ), 10, 2 ); + add_action( 'camptix_form_edit_attendee_additional_info', array( $this, 'get_edit_attendee_username_field' ) ); } /** @@ -36,10 +46,19 @@ class CampTix_Require_Login extends CampTix_Addon { * it will be overriden with the 'login' action so that they first have to login. */ public function block_unauthenticated_actions() { + if ( ! is_user_logged_in() && isset( $_REQUEST['tix_action'] ) && 'login' != $_REQUEST['tix_action'] ) { + //$_GET['tix_action'] = $_POST['tix_action'] = $_REQUEST['tix_action'] = 'login'; - wp_safe_redirect( wp_login_url( site_url( $_SERVER['REQUEST_URI'] ) ) ); + // merge the _post and _get for passing after successful login. + // new array should contain tix_action, tix_tickets_selected, and tix_coupon + // the 3 need to be passed to continue the purchase process after login + $urlData = array_merge( $_POST, $_GET ); + + // had an issue with site_url( $_SERVER['REQUEST_URI'] ) when WP is in a subdirectory + // switched to $GLOBALS['camptix']->get_tickets_url() and appending the query vars to pass on after login + wp_safe_redirect( wp_login_url( $GLOBALS['camptix']->get_tickets_url() . '?' . http_build_query( $urlData ) ) ); exit(); // need to make default login message for standalone camptix installs, but filter it so wordcamp.org can override with special instructions @@ -49,8 +68,86 @@ class CampTix_Require_Login extends CampTix_Addon { // what about edit token and access token, etc. should those be allowed without login? // should you save the previous action and post/get, then restore it once then login? v2 maybe + } else if ( is_user_logged_in() && isset( $_REQUEST['tix_action'] ) && isset( $_GET['tix_tickets_selected'] ) ) { + + // if the ticket(s) requested are in the url, put them in _post so camptix can pick up and run after login + $_POST['tix_tickets_selected'] = $_GET['tix_tickets_selected']; + } + } + + public function ticket_form_message() { + // add message to top of tickets initial form to alert them that they will have to login + if ( ! is_user_logged_in() ) { + $GLOBALS['camptix']->notice( __( 'You will be prompted to login after clicking register.', 'camptix' ) ); + } + } + + public function get_attendee_form_username_field( $form_data, $currentIteration, $totalCount ) { + ?> +