开发者

Seeking a User Role Plugin

开发者 https://www.devze.com 2023-02-09 02:20 出处:网络
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

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:

  1. Create User Account: username/password
  2. Assign user to a page that is private
  3. I want the private page to still appear in the navigation, even though a user may not be logged in.
  4. Once a private page is clicked, they are prompted to enter their username/password. Once they do, they are then redirected to that page.
  5. 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!

0

精彩评论

暂无评论...
验证码 换一张
取 消