Support » Fixing WordPress » Possible to make entire site private without plugin?

  • Resolved vytaulla51

    (@vytaulla51)


    Hi:
    I am researching ways for a client to have a private WordPress website. They will have a public site which explains services, etc. and then they want a set of pages for members only. They will be processing members through a different platform, and would then manually create accounts for those members, giving them user names and passwords to use to get to the private content.

    I see that there are Membership plugins, Password-protect-page plugins, etc. I’m worried about using a plugin that might, down the road, stop being supported. Many articles recommend My Private Site, for instance, but it hasn’t been updated in 9 months.

    I thought about installing a new WordPress install in a subdirectory linked from the public site – I wanted to know if it is possible to make an entire site private without a plugin, or not. Is the only option to use a plugin?

    Thanks for any help/advice –

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Joy

    (@joyously)

    WordPress is for web publishing, which implies public. You have to use a plugin to make a site private.
    Plugins don’t need frequent updates. You can use a really old plugin and be fine.

    Binit

    (@thebinitghimire)

    Yes, you can achieve your requirements without having to install a new plugin. You just have to place a small piece of code in the index.php file of your theme.

    You can follow the steps below:
    Step 1. Visit your WordPress website’s Dashboard.
    Step 2. Hover over “Themes” and click on “Theme Editor”, and it should send you to /wp-admin/theme-editor.php.
    Step 3. By default, the stylesheet file would be opened when you visit “Theme Editor”. So, the next thing you need to do is to find “Main Index Template: index.php” in the “Theme Files” area, and click on it.
    When you do so, it will load the contents of the index.php file of your theme.
    Step 4. Now, place the following code by creating a new line after “<?php“:

    if(!is_user_logged_in()) {
    	wp_redirect( wp_login_url() );
    }

    Step 5. Now, click on the “Update File” button!

    With that being done, try visiting your website without being logged in, and you should see it redirects to the login page without displaying any content of your website.

    I hope you would be able to achieve your requirements by following the above mentioned steps.

    • This reply was modified 1 week, 1 day ago by Binit.
    vytaulla51

    (@vytaulla51)

    Thank you for your comment Joy & thank you for your helpful info @thebinitghimire!

    Binit

    (@thebinitghimire)

    You’re welcome, @vytaulla51!

    Joy

    (@joyously)

    Putting that code into the theme’s index.php will only affect the pages that use index.php. It would not affect single.php or category.php or archive.php or page.php.
    I think what you meant was to put that code into the main WP index.php, but at that point, is the user authenticated?
    This is the logic that a membership plugin has, but it knows where to put the check…

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.