A client of ours is currently using Rolescoper as a WP plugin to manage users' access to various "private" pages and posts. However, Rolescoper hides posts/pages from view unless the user is logged in. We're looking for a plugin that shows all the posts/pages but shows a "access denied" message with a prompt to开发者_运维问答 log-in afterwards.
Here's a list of the requests verbatim:
- Create User Account: username/password
- Assign user to a page that is private
- I want the private page to still appear in the navigation, even though a user may not be logged in.
- Once a private page is clicked, they are prompted to enter their username/password. Once they do, they are then redirected to that page.
- This would also need to be applied to document uploads
Any ideas? I did some Googling/WP plugin searching without much luck.
Thanks!
Maybe rather than using a plugin, try reworking your template to use is_user_logged_in?
I know this is a very old question, but for anyone else who finds it, I'll take a swing.
You could add to the beginning of your while
statement in your single.php
file a "Private" category check and "User Logged In" check, like so (NOTE: redirects to login page if user not logged in and category on post is set to "private"):
while ( have_posts() ) : the_post();
if(in_category("private")){
if(is_user_logged_in()){
get_template_part( 'content', get_post_format() );
} else {
auth_redirect();
}
} else {
get_template_part( 'content', get_post_format() );
}
Is User Logged In?
In Category X?
See also: auth_redirect()
Hope this helps!
精彩评论