Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#57274 closed defect (bug) (duplicate)

As of 6.1 custom meta boxes are not saving information.

Reported by: nbmp1980's profile nbmp1980 Owned by:
Milestone: Priority: normal
Severity: major Version: 6.1
Component: General Keywords: needs-patch reporter-feedback close
Focuses: Cc:

Description

As of 6.1 custom meta boxes are not saving information in the database as they did in all previous versions. If I roll back to version 6.0.3 the meta boxes update correctly. What has changed to prevent meta boxes from saving?

Change History (4)

#1 @nbmp1980
2 years ago

I have found out why it does not work, the original code was:

current_user_can( 'edit_post', $post_id )

WordPress have now changed edit_post to edit_posts:

current_user_can( 'edit_posts', $post_id )

With this updated code it now saves correctly.

#2 @costdev
2 years ago

  • Keywords reporter-feedback close added

Hi @nbmp1980, welcome to Trac!

It seems this issue has now been resolved.

However, can you tell us what WordPress Core file changed 'edit_post' to 'edit_posts'?

#3 @SergeyBiryukov
2 years ago

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 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.

#4 @JeffPaul
2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #57147.

Note: See TracTickets for help on using tickets.