diff --git a/includes/class-access-control.php b/includes/class-access-control.php index 002153b..dfd1b06 100644 --- a/includes/class-access-control.php +++ b/includes/class-access-control.php @@ -27,6 +27,9 @@ class DDHH_JM_Access_Control { // Protect job archive (logged-in users only) add_action( 'template_redirect', array( __CLASS__, 'protect_job_archive' ) ); + + // Protect single job posts (logged-in users only) + add_action( 'template_redirect', array( __CLASS__, 'protect_single_job' ) ); } /** @@ -137,4 +140,22 @@ class DDHH_JM_Access_Control { exit; } } + + /** + * Protect single job posts (logged-in users only) + */ + public static function protect_single_job() { + // Check if current page is single job_offer post + if ( ! is_singular( 'job_offer' ) ) { + return; // Not single job post + } + + // 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; + } + } }