Assuming the comment_author is a User ID, try:
if(user_can($result->comment_author,'manage_options')){
$output .= "<li>".(($result->comment_author_url) ? "<a href="".$result->comment_author_url."">" : "").$result->comment_author.(($result->comment_author_url) ? "</a>" : "")." (".$result->comments_count.")</li>";
}
If not, one can use get_comment
, and select the comment_ID
in the SQL statement. You can then use the object returned to grab the user ID of the comments author, and do a check to see if they are an administrator using the user_can
function from above.
http://codex.wordpress.org/Function_Reference/get_comment
edit:
- you need to the comment_ID. Modify your SQL query to retrieve this.
- inside the foreach loop, call get_comment which will return you a comment object. For an example see here
- From this comment object, grab the user ID of the commenter and assign it to a variable
- call user_can, passing the user ID you got in step 3. you need to check if the user can change options, which only an administrator can do, so we pass in ‘manage_options’ as the second parameter
- if user_can returns false, list the comment
- if user_can returns true, skip to the next comment, this is an administrator comment