Try using the following code in the functions.php file of your child theme theme.
function add_comment_on_post_update( $post_id, $post_after, $post_before ) {
// If this is just a revision, don't send the email.
if ( wp_is_post_revision( $post_id ) )
return;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return;
if (isset($post_before->post_status) && 'auto-draft' == $post_before->post_status) {
return;
}
if ('post' == $_POST['post_type']) {
$current_user = wp_get_current_user();
$comment="Edited by ".$current_user->user_login;
$time = current_time('mysql');
$data = array(
'comment_post_ID' => $post_id,
'comment_author' => 'admin',
'comment_author_email' => '[email protected]',
'comment_author_url' => 'http://www.xyz.com',
'comment_content' => $comment,
'user_id' => $current_user->ID,
'comment_date' => $time,
'comment_approved' => 1,
'comment_type' => 'custom-comment-class'
);
wp_insert_comment($data);
}
}
add_action( 'post_updated', 'add_comment_on_post_update', 10 , 3 );
Best Regards,
Vinod Dalvi