Generally in the website you can see lots pages are restricted to have access before login. If you want to add this feature in your Wordpress website. Please follow the below code in your in page.
if(is_user_logged_in()) {
// Place your page code here
}else{
header('location:' . site_url());
//If non-login user try to access this page then it will redirect to home of your wordpress website.
}
0 Comment(s)