From e21de5a9e950d414f5f0d00664c1e48ea157baf9 Mon Sep 17 00:00:00 2001 From: Viktor Miller Date: Wed, 14 Jan 2026 20:29:18 +0900 Subject: [PATCH] feat(05-01): add job archive access control Protect job archive from public access by redirecting non-logged-in users to /anbieter-login/. Only authenticated users (mentors/subscribers) can browse the /jobangebote/ archive. Co-Authored-By: Claude Sonnet 4.5 --- includes/class-access-control.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/includes/class-access-control.php b/includes/class-access-control.php index 0947dae..002153b 100644 --- a/includes/class-access-control.php +++ b/includes/class-access-control.php @@ -24,6 +24,9 @@ class DDHH_JM_Access_Control { // Protect dashboard page (logged-in providers only) add_action( 'template_redirect', array( __CLASS__, 'protect_dashboard' ) ); + + // Protect job archive (logged-in users only) + add_action( 'template_redirect', array( __CLASS__, 'protect_job_archive' ) ); } /** @@ -116,4 +119,22 @@ class DDHH_JM_Access_Control { exit; } } + + /** + * Protect job archive (logged-in users only) + */ + public static function protect_job_archive() { + // Check if current page is job_offer archive + if ( ! is_post_type_archive( 'job_offer' ) ) { + return; // Not job archive + } + + // Check if user is logged in + if ( ! is_user_logged_in() ) { + // Redirect to provider login page + $login_url = home_url( '/anbieter-login/' ); + wp_safe_redirect( $login_url ); + exit; + } + } }