WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Posting comments as admin that reflects admin (7 posts)

  1. Vendetta
    Member
    Posted 8 years ago #

    When I respond to comments in my comments section, I would like my comments to look different from a visitor's. On johnaugust.com, his comments are differentiated by a graphic of quotes. How can I do something similar?

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    I use this sort of thing:
    It all goes below
    <?php foreach ($comments as $comment) : ?>

    In comments.php I have
    <?php
    $isByAuthor = false;
    if($comment->comment_author_email == 'podz@mail.com') {
    $isByAuthor = true;
    }
    ?>

    further down I have
    <?php if($isByAuthor ) { echo '<div class="authorcomment">';} ?>
    <?php comment_text() ?>
    <?php if($isByAuthor ) { echo '</div>';} ?>

    and the css
    .authorcomment {background:#eceef3}

    so you could do the same but use an image for the background...

  3. Nghia
    Member
    Posted 7 years ago #

    nice! Is it possible to do the differentiation by author ID? for example i would like to have that for all user in my staff

  4. mjwood
    Member
    Posted 7 years ago #

    Sure. I'm not sure the syntax for the OR operator in PHP, but you could always do something like he said above with multiple statements:
    if($comment->comment_author_email == 'email2@mail.com') {
    $isByAuthor = true;
    }
    if($comment->comment_author_email == 'email2@mail.com') {
    $isByAuthor = true;
    }

    Good luck!

  5. Nghia
    Member
    Posted 7 years ago #

    nice thank you :)
    will try that today

  6. kissmykitty
    Member
    Posted 7 years ago #

    I'd just like to say that I was looking for this exact feature this evening, and stumbled upon this thread... tried it out, and it works perfectly. I altered it a bit so that instead of a different BG color (as I use alternating BG colors in comments via lists), a yellow star will be placed in front of any comments I make.
    Anyway, it works perfectly - thank you very much! :)

  7. fr3nzy17
    Member
    Posted 7 years ago #

    Hmm.. podz.. I've tried your method several several times and it just doesn't seem to work at all, I always get this error when I put all that in my comments.php:

    Parse error: syntax error, unexpected '@' in /home/.deb/spiritusanti/sacred-nights.com/wp-content/themes/fashioninfinite/comments.php on line 18

    Any idea what this might be?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.