| 845 | | else |
| 846 | | $distinct = 'DISTINCT'; |
| 847 | | |
| 848 | | if ( is_user_logged_in() ) |
| 849 | | $where .= " OR post_author = $user_ID AND post_status = 'private'))"; |
| 850 | | else |
| 851 | | $where .= '))'; |
| | 845 | |
| | 846 | // Users who can edit other's posts and pages can see all private posts. |
| | 847 | // Users who can edit only their own posts can see only their own private posts. |
| | 848 | if ( is_user_logged_in() ) { |
| | 849 | if ( 'post' == $post_type ) |
| | 850 | $cap = 'edit_others_posts'; |
| | 851 | else |
| | 852 | $cap = 'edit_others_pages'; |
| | 853 | if ( current_user_can($cap) ) |
| | 854 | $where .= "OR post_status = 'private'"; |
| | 855 | else |
| | 856 | $where .= " OR post_author = $user_ID AND post_status = 'private'"; |
| | 857 | } |
| | 858 | } |
| | 859 | |
| | 860 | $where .= '))'; |