1

Is there a way to check if a comment was modified so I can display a modified/edited tag? I can't seem to find anything anywhere or anyone asking about this.

Also it doesn't look like the modified date is stored in the object...

WP_Comment Object
(
    [comment_ID] => 47
    [comment_post_ID] => 1742
    [comment_author] => deleted
    [comment_author_email] => deleted
    [comment_author_url] => deleted
    [comment_author_IP] => deleted
    [comment_date] => 2017-04-29 02:40:59
    [comment_date_gmt] => 2017-04-29 09:40:59
    [comment_content] => test
    [comment_karma] => 0
    [comment_approved] => 1
    [comment_agent] => deleted
    [comment_type] => 
    [comment_parent] => 0
    [user_id] => 1
    [children:protected] => Array
        (
        )

    [populated_children:protected] => 1
    [post_fields:protected] => Array
        (
            [0] => post_author
            [1] => post_date
            [2] => post_date_gmt
            [3] => post_content
            [4] => post_title
            [5] => post_excerpt
            [6] => post_status
            [7] => comment_status
            [8] => ping_status
            [9] => post_name
            [10] => to_ping
            [11] => pinged
            [12] => post_modified
            [13] => post_modified_gmt
            [14] => post_content_filtered
            [15] => post_parent
            [16] => guid
            [17] => menu_order
            [18] => post_type
            [19] => post_mime_type
            [20] => comment_count
        )

)
0

1 Answer 1

2

You should be able to do this fairly simply by hooking to the edit_comment action and saving the modified date using update_comment_meta:

add_action('edit_comment', 'my_comment_modified_date', 10, 2);
function my_comment_modified_date($comment_ID, $data) {
    update_comment_meta($comment_ID, 'modified_date', time());
}
1
  • I kept looking at the comment object, but then realized it was recalled using get_comment_meta
    – gavsiu
    Commented Apr 1, 2018 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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