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!
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/
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
}
?>