WordPress.org

Make WordPress Core

Ticket #33306: only query logged in users if member of site.2.diff

File only query logged in users if member of site.2.diff, 1.5 KB (added by sboisvert, 5 years ago)

Actually attaching the right file.

  • wp-includes/query.php

     
    30463046                       if ( is_user_logged_in() ) {
    30473047                               // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states.
    30483048                               $private_states = get_post_stati( array('private' => true) );
    3049                                foreach ( (array) $private_states as $state )
    3050                                        $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status = '$state'";
     3049                                foreach ( (array) $private_states as $state ) {
     3050                                        if ( current_user_can( $read_private_cap ) ) {
     3051                                                $where .= " OR $wpdb->posts.post_status = '$state'";
     3052                                        } else if ( ! is_multisite() || ( is_multisite() && is_user_member_of_blog() ) ) {
     3053                                                $where .= " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status = '$state'";
     3054                                        }
     3055                                }
    30513056                       }
    30523057
    30533058                       $where .= ')';