{"id":881,"date":"2008-12-20T17:10:44","date_gmt":"2008-12-20T16:10:44","guid":{"rendered":"http:\/\/blog.ginchen.de\/?p=881"},"modified":"2010-03-13T21:27:09","modified_gmt":"2010-03-13T19:27:09","slug":"admin-kommentare-in-wordpress-hervorheben","status":"publish","type":"post","link":"http:\/\/blog.ginchen.de\/en\/2008\/12\/20\/admin-kommentare-in-wordpress-hervorheben\/","title":{"rendered":"Highlighting admin comments in WordPress"},"content":{"rendered":"<p>Many WordPress users wish to visually highlight their own responses between the comments on a post, so that you recognize at the first glance which comments come from the site operator and which ones from normal visitors. So do I.<br \/>\r\nA Google search revealed that it is most often being recommended to simply compare the commentator&#8217;s user ID with your own one, and if they match, assign a second, special CSS class to the comment. That would look something like this:<\/p>\r\n\r\n<pre lang=\"php\">\r\n<li class=\"comment<?php if($comment->user_id == 1) echo ' admincomment'; ?>\">\r\n<\/pre>\r\n\r\n<p>I don&#8217;t like that very much. What if a site has multiple writers and you would like to highlight the comments of all of them? Should it look like this then?<\/p>\r\n\r\n<pre lang=\"php\">\r\n<li class=\"comment<?php if($comment->user_id == 1 || $comment->user_id == 3 || $comment->user_id == 13 || $comment->user_id == 753) echo ' admincomment'; ?>\">\r\n<\/pre>\r\n\r\n<p>I think we all agree that this is not very beautiful. ;) Besides, each time you admit a new member to your &#8220;editorial team&#8221;, you would have to fiddle around with the template again in order to enter his user ID there.<br \/>\r\nNo, no, that&#8217;s not the way you do it. It would be a lot better if you simply checked the commentator&#8217;s user level, because if it is above 0, you know that you are dealing with one of the site&#8217;s &#8220;staff members&#8221;.<\/p>\r\n\r\n<p>That will look like this:<\/p>\r\n\r\n<pre lang=\"php\">\r\n<? $userdata = get_userdata($comment->user_id); ?>\r\n<li class=\"comment<?php if($userdata->user_level > 0) echo ' admincomment'; ?>\">\r\n<\/pre>\r\n\r\n<p>This way, all comments from contributors (level&nbsp;1), authors (level&nbsp;2-4), editors (level&nbsp;5-7) and admins (level&nbsp;8-10) will get a different style. Of course, you can even refine the whole thing with the aid of these levels, e.&nbsp;g. if you only want to change the appearance of admin and editor comments, but not the one of author and contributor comments.<\/p>","protected":false},"excerpt":{"rendered":"Many WordPress users wish to visually highlight their own responses between the comments on a post, so that you recognize at the first glance which comments come from the site operator and which ones from normal visitors. So do I. A Google search revealed that it is most often being recommended to simply compare the [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[77],"tags":[164,165,169,166,167,168,162,170,161,606,163,105],"_links":{"self":[{"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/posts\/881"}],"collection":[{"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/comments?post=881"}],"version-history":[{"count":11,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/posts\/881\/revisions"}],"predecessor-version":[{"id":3257,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/posts\/881\/revisions\/3257"}],"wp:attachment":[{"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/media?parent=881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/categories?post=881"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/tags?post=881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}