add_action(‘template_redirect’, function () {
// Yönlendirmek istediğiniz sayfanın slug’ı veya path’i
$protected_path = ‘/kontrol-paneli/user-account/’;
// Giriş sayfanızın yolu (değiştirin)
$login_url = site_url(‘/uye-giris/’);
// Mevcut isteğin path kısmı
$current_path = parse_url($_SERVER[‘REQUEST_URI’], PHP_URL_PATH);
// Sadece hedef sayfada çalışsın
if (trailingslashit($current_path) === $protected_path) {
// Kullanıcı giriş yapmadıysa login’e yönlendir
if (!is_user_logged_in()) {
// İsterseniz geri dönülecek sayfayı da ekleyin:
$redirect_back = urlencode(home_url($current_path));
wp_safe_redirect($login_url . ‘?redirect_to=’ . $redirect_back, 302);
exit;
}
}
});