[wp-trac] [WordPress Trac] #57274: As of 6.1 custom meta boxes are not saving information.

WordPress Trac noreply at wordpress.org
Thu Dec 15 13:01:38 UTC 2022


#57274: As of 6.1 custom meta boxes are not saving information.
-------------------------------------------------+-------------------------
 Reporter:  nbmp1980                             |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  General                              |     Version:  6.1
 Severity:  major                                |  Resolution:
 Keywords:  needs-patch reporter-feedback close  |     Focuses:
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 Hi there, thanks for the ticket!

 This appears to be similar to (or perhaps a duplicate of) #57147.

 As noted in comment:10:ticket:44591, these capabilities check for a
 particular post and do require a post ID:

 * `current_user_can( 'delete_post', $post_id )`
 * `current_user_can( 'edit_post', $post_id )`
 * `current_user_can( 'read_post', $post_id )`
 * `current_user_can( 'publish_post', $post_id )`

 [53408] / #44591 aimed to address this in a consistent way. Performing
 these checks without passing in a post ID is not supported and could only
 work by accident. See the discussion in #56962 for more details.

 Replying to [comment:1 nbmp1980]:
 > I have found out why it does not work, the original code was:
 >
 > current_user_can( 'edit_post', $post_id )

 This code should still be fine, as long as `$post_id` is set up correctly
 and points to an existing post ID.

 > WordPress have now changed edit_post to edit_posts:
 >
 > current_user_can( 'edit_posts', $post_id )

 With the `edit_posts` capability, `$post_id` is not required, just
 `current_user_can( 'edit_posts' )` is enough.

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


More information about the wp-trac mailing list