• Hello everyone,

    I been on this for many days but haven’t found any plugin that does this.
    The built in WP functions of “Password Protect” and “Private” do not fit well.

    There is a thread I came across but it’s currently closed to new replies.

    I’m not a programmer but I tried the code they provided:

    function somefunction($content) {
            if ( !is_user_logged_in() )
                    echo "...put something here if not logged in";
            else
                    return $content;
    }
    
    add_filter('the_content', 'somefunction');

    It works perfectly for regular posts but, could someone please tell me how can I make it work with any custom posts types?

    I would really appreciate that!

    Furthermore, how can I insert HTML on the code above?

    Instead simple having one line of text reading: “…put something here if not logged in”
    I would like to say:

    <h1 style="text-align: right;"><img class="alignright size-full wp-image-4" src="https://www.domain.com/wp-content/uploads/login.png" alt="Mate!" width="193" height="250" /><span style="color: #ffffff;">WHOA!</span>
    <br> Not so fast mate!</h1>
    <h6 style="text-align: right;"><a href="https://www.domain.com/">Register</a> or <a href="https://www.domian/wp-login.php">Login</a> to view this custom post.</h6>
  • The topic ‘How to make all custom posts visible to logged in users only’ is closed to new replies.