WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Private WP] Edit so that front page is displayed to non-loggedin users? (2 posts)

  1. SoItBegins
    Member
    Posted 1 year ago #

    I am using the plugin Private WP, whose sole purpose is to keep non-logged-in users out of your blog. I want to modify it to show the home page, but allow access to no other part of the site if you're not logged in.

    Here is the entire code of the plugin:

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

    I tried changing if (!is_user_logged_in()) to if (!is_user_logged_in() && !is_front_page()), but it didn't work. Does anyone have any idea as to the nature of the problem?

  2. bcworkz
    Member
    Posted 1 year ago #

    I have no idea. I added the noted plugin code to my generic testing plugin on my xampp test server, including your change, and it works perfectly. Nothing wrong with your change, the problem lies elsewhere.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.