meds
meds

Reputation: 22916

Wordpress, when using the "comment_text" action is it possible to get commenter information?

Is it possible to get information about the commenter with the comment_text action in wordpress?

What I want to do is modify a comment someone makes based on who they are, like if they are user_a I might want to make their comments show up as green, if they are user_b I might want their comments to be bolded, or formatted differently.

Upvotes: 0

Views: 402

Answers (1)

Alex
Alex

Reputation: 12433

Use the function get_comment_text

$comment = get_comment_text();
var_dump($comment); 

Untested, but usually a function prefixed by "get_" in wordpress returns the value instead of directly echoing it.

Anyway, you need the author's information too, so you have to get the comments via get_comments and loop through them.

http://codex.wordpress.org/Function_Reference/get_comments

$comments = get_comments('post_id=15');
  foreach($comments as $comm) :
    echo($comm->comment_author);
  endforeach;

Upvotes: 1

Related Questions