WordPress.org

Ready to get started?Download WordPress

Forums

How to block unregistered users from viewing a post (3 posts)

  1. ernestg
    Member
    Posted 2 years ago #

    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?

  2. ernestg
    Member
    Posted 2 years ago #

    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 } ?>
  3. sameera.c.a
    Member
    Posted 2 years ago #

    Thank you!!!

Topic Closed

This topic has been closed to new replies.

About this Topic