Make WordPress Core


Ignore:
Timestamp:
10/10/2018 08:48:21 PM (6 years ago)
Author:
danielbachhuber
Message:

REST API: Enable users with read_private_posts to query for them.

An authorized request with the read_private_posts capability for a post type should be able to GET /wp/v2/posts for posts of status=private. This query is further sanity-checked by WP_REST_Posts_Controller->check_read_permission(), which is unchanged.

Props rachelbaker, soulseekah, twoelevenjay.
Fixes #43701.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r43682 r43694  
    24992499            $post_type_obj = get_post_type_object( $this->post_type );
    25002500
    2501             if ( current_user_can( $post_type_obj->cap->edit_posts ) ) {
     2501            if ( current_user_can( $post_type_obj->cap->edit_posts ) || 'private' === $status && current_user_can( $post_type_obj->cap->read_private_posts ) ) {
    25022502                $result = rest_validate_request_arg( $status, $request, $parameter );
    25032503                if ( is_wp_error( $result ) ) {
Note: See TracChangeset for help on using the changeset viewer.