简体   繁体   中英

How do I enable member login to a specific directory including sub-directories in wordpress

I have created a web application where I want only member access. They should log in to access the directory and all its sub-directories and files.

Is there a plugin for this?

Example; My app folder is in the root wordPress installation directory.

http://localhost/wordpress-site/webapp

Under the webapp, I have the index.php to that launches the application.

I would like to redirect users to login before accessing the webapp.

You can create a file and use the function is_user_logged_in .

For example: page-member.php

1º - Create a page called "member".

2º - Create a file page-member.php and upload to your theme directory.

3º - In the file, you can use something like this:

<?php
if(is_user_logged_in()) {
echo 'you are logged guy! see this content...';
// Here you can put your content
} else {
echo 'login to acess this page';
// Here you can put the login form
}
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM