From 3052e3b70eefe41c7bfb7dd6d44df3242e66f55c Mon Sep 17 00:00:00 2001 From: Steven Dufresne Date: Wed, 23 Oct 2024 14:27:01 +0900 Subject: [PATCH] Don't show login banner if no tickets exist. (#1403) --- .../wp-content/plugins/camptix/addons/require-login.php | 2 +- public_html/wp-content/plugins/camptix/camptix.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/public_html/wp-content/plugins/camptix/addons/require-login.php b/public_html/wp-content/plugins/camptix/addons/require-login.php index 67111d711..53f4141cb 100644 --- a/public_html/wp-content/plugins/camptix/addons/require-login.php +++ b/public_html/wp-content/plugins/camptix/addons/require-login.php @@ -123,7 +123,7 @@ public function ticket_form_message() { } // Warn users that they will need to login to purchase a ticket - if ( ! is_user_logged_in() && ! $this->user_is_editing_ticket() ) { + if ( ! is_user_logged_in() && $camptix->has_tickets_available() && ! $this->user_is_editing_ticket() ) { $camptix->notice( apply_filters( 'camptix_require_login_please_login_message', sprintf( diff --git a/public_html/wp-content/plugins/camptix/camptix.php b/public_html/wp-content/plugins/camptix/camptix.php index f40992a29..f28a1164f 100644 --- a/public_html/wp-content/plugins/camptix/camptix.php +++ b/public_html/wp-content/plugins/camptix/camptix.php @@ -8586,6 +8586,15 @@ public function is_wordcamp_closed() { $wordcamp = get_wordcamp_post(); return 'wcpt-closed' === $wordcamp->post_status; } + + /** + * Return whether there are available tickets. + * + * @return bool + */ + public function has_tickets_available() { + return $this->number_available_tickets() > 0; + } } // Initialize the $camptix global.