Support » Plugins » Comparing 2 Functions

  • Resolved wajih



    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 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • wajih


    I resolved it!

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




    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.

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Comparing 2 Functions’ is closed to new replies.