How to force login for visitors in wordpress


How to force login for visitors in wordpress ?

To make it happen just add the below code to your theme header

// Require login for site
get_currentuserinfo();
global $user_ID;
if ($user_ID == ”) {
header(‘Location: /wp-login.php’); exit();
}

Also you can change the location to any url you want

Comments & Responses

You must be logged in to post a comment.