A blog for technology, SEO tips, website development and open source programming.

How to make WordPress private?

0 606

In this article I will explain you how to make your WordPress private only to registered users.

Steps

  1. Open file  functions.php

  2. Copy and paste the following code:


function private_wp() {
if (!is_user_logged_in()) {
auth_redirect();
}
}
add_action('get_header', 'private_wp');
?>

When this code is called from a page, it checks to see if the user viewing the page is logged in. If the user is not logged in, they are redirected to the login page. The user is redirected in such a way that, upon logging in, they will be sent directly to the page they were originally trying to access.

Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More