Check if comment was modified

时间:2018-04-01 作者:gavsiu

是否有方法检查注释是否已修改,以便显示修改/编辑的标记?我似乎找不到任何地方或任何人询问这件事。

而且,看起来修改的日期并没有存储在对象中。。。

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
        )

)

1 个回复
最合适的回答,由SO网友:majick 整理而成

您应该能够通过挂接edit_comment 操作并使用保存修改的日期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());
}

结束