How to lock content?

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).

Leave a Comment