What is the easiest method to make all my articles accessible only to registered users?

My homepage contains titles and excerpts but I want to allow access to the full content only to registered users.

I remember there was an admin setting for that but I cannot find it.

Maybe Im wrong. Any ideas?


2 Answers 2


You could hook into template_redirect, check if it is a singular page (post, page, custom post type) and force a log in:

add_action( 'template_redirect', 'login_to_see_content' );

function login_to_see_content()
    if ( is_singular() && ! is_user_logged_in() )
        auth_redirect(); // does nothing for logged in users

As suggested by @s_ha_dum in the comments, an additional ! is_user_logged_in() might be necessary. In theory, it shouldn’t (and it isn’t in my setup).

  • Thanks. Where do I add this? functions.php ?
    – p.a.
    May 24, 2013 at 7:14
  • @p.a. Make a little plugin, so you can turn it off easily.
    – fuxia
    May 24, 2013 at 7:15
  • Thanks, my needs are minimal so I ll just drop this into functions.php. I just check for a "public" category and redirect for all other categories to the login box.
    – p.a.
    May 24, 2013 at 10:02
  • No it does not work; it always redirects me to login. Even if I am connected as admin! In addition, when redirected, login does not work! I supply valid credentials and return to login screen.
    – p.a.
    May 24, 2013 at 15:43
  • @p.a. I tested my solution: It works. Do you have by any chance another plugin enabled that breaks this functionality?
    – fuxia
    May 24, 2013 at 18:09

I recommend a plugin like User Access Manager for that purpose. It gives more function and control than using native function such as making posts Private.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.