Forums

Restrict access outside WordPress (3 posts)

  1. Licorne
    Member
    Posted 5 years ago #

    Hello! I want to make a file that is located outside of my wordpress folder, but I still want that only registered users will be able to access it.

    Something like:

    ..code here to check if user is registered and logged in...
    ...content that I want to show..
    ..else if user is not logged in or registered, redirect to main page...

    what files or functions to i need to include to the file to make it work? Thank you!

  2. upekshapriya
    Member
    Posted 5 years ago #

    HideThis plugin may be what you want. It hides a selected portion of your post from readers who are not logged in.

    http://edwards.org/2006/03/12/hidethis-v10-plugin-for-wordpress/

  3. Otto
    Tech Ninja
    Posted 5 years ago #

    what files or functions to i need to include to the file to make it work?

    <?php
    // first, we include the blog code
    require('/path_to_your_WP_directory/wp-blog-header.php');
    // check if the user is logged in
    if (is_user_logged_in())
    {
    // do logged in stuff
    }
    else
    {
    // do something else
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic