• I want just the user with the id of 3 to see this text.

    “<p>This text is only visible to user 3.</p>”

    This is what I have so far. I’ve tested it and it’s not working out.

    <?php if ( $user_id == 3 ) {?>
    		<p>This text is only visible to user 3.</p>
    <?php } ?>

    I’m still new to php and WP’s built in php tags, and i’m obviously not going about this the right way. If anyone has any ideas I would be very appreciative. Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Where are you assigning the value of $user_id?

    Try:

    <?php $user_id = get_current_user_id(); ?>
    <?php if ( $user_id == 3 ) { ?>
        <p>This text is only visible to user 3.</p>
    <?php } ?>
    Thread Starter codyt

    (@codyt)

    Sorry I forgot to post that bit in my code. I had used get_current_user.
    It’s working perfectly now thanks a ton!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$user_id can see this text.’ is closed to new replies.