WordPress.org

Ready to get started?Download WordPress

Forums

Restrict access to logged in users? (3 posts)

  1. superwad
    Member
    Posted 5 years ago #

    I want to be able to tie in the WordPress database with my own site database, so that logged in users are able to access additional pages or categories, in addition to the regular pages and categories that non-authenticated users can still access.

    Is this possible?

    Also, is there a guide somewhere that can explain how to integrate my site (custom PHP codebase) with WordPress, so that WordPress authenticates solely with my system?

    Thanks.

  2. Eric Mann
    Member
    Posted 5 years ago #

    I found a plugin the other day that allows you to use an external means to authenticate users within WordPress: http://wordpress.org/extend/plugins/http-authentication/ This might be what you're looking for if you can get your external site to work with it properly.

    Restricting pages within WordPress to registered, signed-in users is actually quite simple.

    1. Create a new page template (by copying page.php, renaming it, and uploading it back to the server).
    2. Add the following to the top part of the page template:
    3. Find the line "<div class="post-content"><?php the_content() ;?></div>" and change it to:
    4. <div class="post-content">
      <?php global $user_ID;
            get_currentuserinfo();
      ?>
      <?php if($user_ID) {
            the_content();
            } else {
            echo '<p style="font-size: 36px;"><center><a href="' . get_settings('home') . '/wp-login.php?action=register">Please Register!</a></center></p>';
            echo '<p style="font-size: 11px; font-family: Arial, Helvetica, sans-serif;">You must be a registered user to view this page.</p>';
      }
      ?>
      </div>

    This script checks to see if the user is logged in. If they are, then the page will display normally. If not, then they'll see a message asking them to register.

  3. superwad
    Member
    Posted 5 years ago #

    I found a module that does exactly what I want.

    http://wordpress.org/extend/plugins/external-database-authentication/

    I tell it what database, table and fields to look for when authenticating, then WordPress takes care of the rest for me. No more fussing, no fancy editing of anything.

    Thanks for the suggestion! It got me searching in the right direction :)

Topic Closed

This topic has been closed to new replies.

About this Topic