[wp-trac] [WordPress Trac] #41262: API REST, create_posts and edit_posts are inversed

WordPress Trac noreply at wordpress.org
Mon Jul 10 07:23:14 UTC 2017


#41262: API REST, create_posts and edit_posts are inversed
-----------------------------+-----------------------
 Reporter:  stephanedemotte  |       Owner:
     Type:  defect (bug)     |      Status:  closed
 Priority:  normal           |   Milestone:
Component:  Role/Capability  |     Version:  4.8
 Severity:  normal           |  Resolution:  invalid
 Keywords:                   |     Focuses:  rest-api
-----------------------------+-----------------------
Changes (by rmccue):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 The problem here isn't really that `create_posts` and `edit_posts` are
 swapped, but rather creating a post also requires that you have access to
 edit it. We check `$post_type->cap->create_posts`, which for posts, is the
 default `edit_posts` ([source:trunk/src/wp-
 includes/post.php at 40925:1280-1282#L1280 set in
 get_post_type_capabilities]).

 Since the REST API just inherits WordPress' behaviour here, you need to
 change the underlying core behaviour if you want to achieve this. You
 could do this with a plugin, and hook into `register_post_type_args` to
 change the default post types' capabilities when they're registered.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41262#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list