How to display number of flagged comments for each author I am trying to copy the "thanked"-function seen in vBulletin forums. Here the author of a topic can thank the author of a comment and the number of comments a person have been thanked for is shown in the author pane.

I have used the Flag module to allow a comment-specific flag but I can't figure out how to display the count number of thanks for each user. I have tried to create a view and display it with views_embed_view but i don't know how to choose count for the specific author? I have also thought of using entityfieldquery but I don't think it can see which comments that are flagged?

Is there a solution to my problem?
Ok so I found a solution although I am not sure it is the best one. The problem was that the databases for the flag module only stores the comment id (when using a comment flag) and not the id of the authoring user. I am implementing the code in a PHP snippet in author pane template where the comment object isn't available. My solution was to do two queries:

$cid_array = db_query("SELECT cid FROM comment WHERE uid = :user", array(':user' =&gt; $account-&gt;uid))-&gt;fetchCol();
$thank_count = db_query("SELECT COUNT(*) FROM flagging WHERE entity_id IN (:cid) AND fid = 2", array(':cid' =&gt; $cid_array))-&gt;fetchField();


Thanks to Felix Eve for supportive comments