Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Protect custom content type from not logged in users

/* By Tareq from http://wordpress.stackexchange.com/questions/37551/making-custom-post-type-visible-for-only-logged-in-users */

function tp_stop_guestes( $content ) {
    global $post;

    if ( $post->post_type == 'YOUR_CUSTOM_POSTTYPE' ) {
        if ( !is_user_logged_in() ) {
            $content = 'Please login to view this post';
        }
    }

    return $content;
}

add_filter( 'the_content', 'tp_stop_guestes' );