mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-08 14:44:37 +00:00
Ensure the correct error message is returned when a user attempts to comment on a post to which they do not have access.
Adds more tests. git-svn-id: https://develop.svn.wordpress.org/trunk@35745 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2670,6 +2670,10 @@ function wp_handle_comment_submission( $comment_data ) {
|
||||
// get_post_status() will get the parent status for attachments.
|
||||
$status = get_post_status( $post );
|
||||
|
||||
if ( ( 'private' == $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) {
|
||||
return new WP_Error( 'comment_id_not_found' );
|
||||
}
|
||||
|
||||
$status_obj = get_post_status_object( $status );
|
||||
|
||||
if ( ! comments_open( $comment_post_ID ) ) {
|
||||
@@ -2756,7 +2760,7 @@ function wp_handle_comment_submission( $comment_data ) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( get_option( 'comment_registration' ) || 'private' == $status ) {
|
||||
if ( get_option( 'comment_registration' ) ) {
|
||||
return new WP_Error( 'not_logged_in', __( 'Sorry, you must be logged in to post a comment.' ), 403 );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user