[resolved] Comparing 2 Functions (4 posts)

  1. wajih
    Posted 8 years ago #


    Well I'm trying to modify my comments.php file in order to change the background color (change the CSS of comments) so that if a regular user post a comment, a particular style will be applied, and if the author of the post itself replies (hence post), another style will be applied.

    Here is what I did, which does not work (keep in mind that I am completely new, even to PHP):

    if( the_author() == comment_author )
        // then do this set of code
       // then do that set of code.

    So what it is doing, instead of of comparing the two, it is outputting (echo'ing) on the webpage. In this case, the_author is admin, and comment_author is also admin, and it is outputting adminadmin (1 word), and outputs the code which is in my else() statement.

    So am I doing wrong?

    Thanks for your help :)

  2. wajih
    Posted 8 years ago #

    I resolved it!

    I just replaced the_author() and comment_author() by get_the_author() and get_comment_author() respectively, and it works flawlessly :)


  3. drphil9001
    Posted 8 years ago #

    I believe that you want get_the_author() instead of the_author(). If you look at author_template.php you will see that the later echos the result of the former.

  4. spacebrew
    Posted 7 years ago #

    Can anyone suggest a way to do the same thing you're doing here, but for multiple authors?

    Basically what I want is for anyone who is a contributor or above, their comments are a certain class, where just subscribers have a separate style. Any help is appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic