WordPress.org

Forums

How would I wrap this in an "if" statement (4 posts)

  1. Mark_I
    Member
    Posted 7 years ago #

    For my registered commenters, I'd like to add this link to my comment template:

    <a href="?author=<?php echo $comment->user_id ?>"><?php comment_author() ?></a>

    What would I put around that code so that the link only appears for comments left by registered users?

    I still want others to be able to comment, but I'd like this link to appear for the comments left by registered users.

    Thanks!

  2. Mark_I
    Member
    Posted 7 years ago #

    figured it out! here it is in case others are interested:

    <?php if ($comment->user_id) { ?>
    <a href="?author=<?php echo $comment->user_id ?>"><?php comment_author() ?></a>
    <?php } ?>
  3. Mark_I
    Member
    Posted 7 years ago #

    argh. I spoke too soon.

  4. Try if (!empty($comment->user_id)).

Topic Closed

This topic has been closed to new replies.

About this Topic