How to: Restrict page view to authenticated users – WordPress

To check if the current reader is authenticated or not, WordPress provide theĀ is_user_logged_in()function, which will return true if user is logged in, false otherwise.

We just have to create a basic php conditional instruction and check if the user is logged in:

if (is_user_logged_in()) {

// You page code goes here
} else {
echo "You must be logged in to view this page.";

Insert the code above in a new page template. When you’ll want to make a private page, just use this template.