Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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;
                    get_currentuserinfo();
                    ?>
                    <div id="userinfo">
                      <p>Logged in as:</p>
                      <p>
                      <?php echo ($current_user->user_firstname.' '.$current_user->user_lastname); ?>
                      </p>
                      <div  class="b_logout"><a href="<?php echo wp_logout_url(home_url()); ?>">Log out</a></div>
                    </div>
                <?php 
                } else { ?>
                    <div id="b_login">
                      <ul><li><a href="/login">Log in</a></li></ul>
                    </div>
                <?php } /* end if user logged in */ ?>
share|improve this answer

Your Answer

 
discard

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.