Is there any way to find out what moderators have approved a comment, and then display that information on the front-end?


John says: "This is a great article" - Approved by Admin1

  • 1
    This kind of data is not saved natively. So you will need to start capturing and storing such info first. – Rarst Jun 29 '11 at 18:59
  • sigh I thought so alright. I really need to get myself a developer :( Thanks for the help Rarst! – James Jun 29 '11 at 19:08
  • 1
    @Rarst would we be talking hooking into something like: add_action('comment_unapproved_to_approved', 'comment_approved'); – MartinJJ Jun 29 '11 at 20:32
  • @Martin no idea, hadn't looked at code. There are multiple ways that comments are dealt with (admin, notification emails, XML-RPC) and I am not sure how hookable all of it is. – Rarst Jun 29 '11 at 20:46

To record the moderator that approves the comment:

function wpse_comment_moderator_log( $comment ) {
    global $current_user;

    update_comment_meta( $comment->comment_ID, 'approved_by', $current_user->user_login );
add_action( 'comment_unapproved_to_approved', 'wpse_comment_moderator_log' );

To display it after the comment text:

function wpse_display_moderator( $comment_text, $comment ) {
    $approved_by = get_comment_meta( $comment->comment_ID, 'approved_by', true );
    if ( $approved_by ) {
        $comment_text .= " - Approved by $approved_by";
    return $comment_text;
add_filter( 'comment_text', 'wpse_display_moderator', 99, 2 );
  • 2
    +1 @Hameedullah, i was just building the display function for my effort.. comforting to know for a learner like myself that my record function is almost exact to yours so i was on the right track.... – MartinJJ Jun 29 '11 at 21:29
  • 2
    Glad we both are on right track, as I am myself still a learner. – Hameedullah Khan Jun 29 '11 at 21:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.