WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible in wordpress,by editing theme functions.php, to stop user access for all pages except Home, about-us, contact-us until a user is logged in to the system? All buddypress and wordpress page and posts redirects user to a login page?

share|improve this question

You could try the Members plugin to restrict access to certain pages, very handy.

In the menu section you can check if user is logged in, and show extra menu items if logged in by adding code similar to this in your template

                if ( is_user_logged_in() ) {
                    wp_nav_menu( array( 'theme_location' => 'logged-in-menu' ) ); /* logged in menu is a separate menu */
                    global $current_user;
                    <div id="userinfo">
                      <p>Logged in as:</p>
                      <?php echo ($current_user->user_firstname.' '.$current_user->user_lastname); ?>
                      <div  class="b_logout"><a href="<?php echo wp_logout_url(home_url()); ?>">Log out</a></div>
                } else { ?>
                    <div id="b_login">
                      <ul><li><a href="/login">Log in</a></li></ul>
                <?php } /* end if user logged in */ ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.