尝试在函数中使用以下代码。您的php文件child 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 );
向你问好,维诺德·达尔维