People who have used WordPress should know that WordPress articles cannot be commented before they are published, but as a diligent webmaster, I don’t need to do this, because most of my articles are prepared in advance, in order to highlight the activity of the article degree, I need to add comments to each article in advance. But because you can't comment on the article before it is published, I want to cancel this restriction.
solution
1. Find the /wp-includes/comment.php file
查找:if ( current_user_can( 'read_post', $comment_post_ID ) ) {
Delete the following lines of code
if ( current_user_can( 'read_post', $comment_post_ID ) ) {
return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 );
} else {
return new WP_Error( 'comment_on_draft' );
}
OK, successfully resolved.