From c3bc6af6ebb17240f9f269b978f968ffda5e21c5 Mon Sep 17 00:00:00 2001 From: Sorin Marta Date: Mon, 20 Jul 2026 21:36:24 +0300 Subject: [PATCH] Redirect User Listings to custom login URL Match Place Ad auth redirect when login-url and registration are set. --- frontend/class-query.php | 7 +++++++ includes/class-authentication-redirection-handler.php | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/frontend/class-query.php b/frontend/class-query.php index 6c0fd8410..6e5645341 100644 --- a/frontend/class-query.php +++ b/frontend/class-query.php @@ -50,6 +50,13 @@ public function is_reply_to_listing_page() { return $this->is_page_that_has_shortcode( 'AWPCPREPLYTOAD' ); } + /** + * @since x.x + */ + public function is_user_listings_page() { + return $this->is_page_that_has_shortcode( 'AWPCPUSERLISTINGS' ); + } + public function is_browse_listings_page() { return $this->is_page_that_has_shortcode( 'AWPCPBROWSEADS' ); } diff --git a/includes/class-authentication-redirection-handler.php b/includes/class-authentication-redirection-handler.php index 2d8237a61..fadc77c96 100644 --- a/includes/class-authentication-redirection-handler.php +++ b/includes/class-authentication-redirection-handler.php @@ -32,6 +32,8 @@ public function maybe_redirect() { $page_requires_authentication = $this->post_listing_page_requires_authentication(); } elseif ( $this->query->is_reply_to_listing_page() ) { $page_requires_authentication = $this->reply_to_listing_page_requires_autentication(); + } elseif ( $this->query->is_user_listings_page() ) { + $page_requires_authentication = $this->user_listings_page_requires_authentication(); } else { $page_requires_authentication = false; } @@ -49,6 +51,13 @@ private function reply_to_listing_page_requires_autentication() { return $this->settings->get_option( 'reply-to-ad-requires-registration' ); } + /** + * @since x.x + */ + private function user_listings_page_requires_authentication() { + return $this->settings->get_option( 'requireuserregistration' ); + } + private function redirect_to_login_page( $login_url ) { wp_safe_redirect( add_query_arg( 'redirect_to', urlencode( awpcp_current_url() ), $login_url ) ); exit();