WordPress.org

Support

Support » Plugins and Hacks » How to block unregistered users from viewing a post

How to block unregistered users from viewing a post

  • ernestg

    @ernestg

    I’ll explain what I want to do in pseduo code.

    if catergory = Cars && user is unregistered
    <my code>
    else
    <my code>

    Anyone know how I would go about writing that?

Viewing 2 replies - 1 through 2 (of 2 total)
  • ernestg

    @ernestg

    If anyone finds this in the future. The code that was the solution goes as follows.

    <?php
    
        if ( in_category( 'Cars' ) && ! is_user_logged_in() ) { ?>
    
    <!-- HTML markup here -->
    
    <?php } else { ?>
    
    <!-- other HTML markup here -->
    
    <?php } ?>

    Thank you!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to block unregistered users from viewing a post’ is closed to new replies.
Skip to toolbar