WordPress.org

Ready to get started?Download WordPress

Forums

Conditional Tags on User or User Role/Type (3 posts)

  1. Sandeep "The Shawn" Tripathy
    Member
    Posted 1 month ago #

    I am trying to check if the logged in user is the same as the author who created the post/apge. If this results in true then I want to display some text, if not something else. for now I'm using :

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    <?php if(is_user_logged_in() == the_author() ) : ?>
      <p>You wrote this post</p>
    <?php else: ?>
      <p>You didn't write this post</p>
    <?php endif ?>

    I also want to use the above to check the user role.
    Turns out, it nothing works.
    Help appreciated.

  2. I haven't tried your code yet but where are you inserting that code? In your theme that you're working on or a plugin?

  3. Sandeep "The Shawn" Tripathy
    Member
    Posted 1 month ago #

    I am inserting it on top of single-post.php in my child theme.

Reply

You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 1 month ago by Sandeep "The Shawn" Tripathy
  • Latest reply from Sandeep "The Shawn" Tripathy
  • This topic is not resolved
  • WordPress version: 3.9.2