• I setup wordpress being hosted on godaddys servers. When you browse to my domain/website, I want the main page to be password protected with the WordPress login screen.

    Currently, when you browse to https://www.ancevic.com it takes you directly to the wordpress blog bypassing the main wordpress login screen. Can someone help me please? Thanks!! ??

    Brad

Viewing 5 replies - 1 through 5 (of 5 total)
  • WP (and most WP themes) are written with the expectation that you will want anybody in the world to be able to read your blog.

    If you want to prevent people from seeing any of your blog without logging in, here’s one way:

    Open up your theme’s header.php. At the very top, put something like this. I haven’t tested this, but it should work:

    <?php
    if ( !is_user_logged_in() ){
      header('Location: https://www.ancevic.com/wp-login.php');
      wp_die( 'Please <a href="https://www.ancevic.com/wp-login.php">log in</a> so you can see our blog!' );
    }
    ?>

    Yeah, that works.

    How can I make it so that once users log in, they are taken to the front page. With the php call you wrote, when you log in you are taken to the dashboard.

    Thanks,

    Anyone?

    Try changing the header() line to:

    header('Location: https://www.ancevic.com/wp-login.php?redirect_to=https://www.ancevic.com/');

    Thanks for the response Kafka,

    Some weirdness ensued when I made that change. First, about 25% of the time tried to load the blog I got a “page cannot be displayed error”. Then when the page did load, and I logged in, the redirect did not work. Still just went to the dashboard.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘password protect main page’ is closed to new replies.