WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 5 weeks ago

#47181 new defect (bug)

Custom post type meta won't save in new editor for user role Author

Reported by: Guido07111975 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 5.2
Component: Editor Keywords:
Focuses: Cc:
PR Number:

Description

Hi,

When using the new editor as author I've noticed the custom post type meta fields aren't being saved. Admin and editor don't have this problem. Also classic editor works as expected.

More info can be found in [this thread]https://wordpress.org/support/topic/custom-post-meta-not-saved-for-author/

Have created a tiny example plugin for testing purposes, which can be found [here]http://www.webmastergroningen.nl/wordpress/cpt-plugin/

Guido

Change History (2)

#1 @ourakland
5 weeks ago

  • Severity changed from normal to major

I'm having the same problem. For editor and above, my code to check and save metadata works as desired. For author, the basic post data is saved, but by the time my save_tour_fields_meta() function is called, $_POST is empty.

The capabilities for author vs. editor are below. I've removed delete_published_posts and moderate_comments from the author role. I tried it without removing those, but still no joy.

WP_Role::__set_state(array(
   'name' => 'author',
   'capabilities' => 
  array (
    'edit_published_posts' => true,
    'publish_posts' => true,
    'read' => true,
    'level_2' => true,
    'level_1' => true,
    'level_0' => true,
    'edit_posts' => true,
    'upload_files' => true,
    'delete_posts' => true,
    'edit_post' => true,
  ),
))

WP_Role::__set_state(array(
   'name' => 'editor',
   'capabilities' => 
  array (
    'moderate_comments' => true,
    'manage_categories' => true,
    'manage_links' => true,
    'upload_files' => true,
    'unfiltered_html' => true,
    'edit_posts' => true,
    'edit_others_posts' => true,
    'edit_published_posts' => true,
    'publish_posts' => true,
    'edit_pages' => true,
    'read' => true,
    'level_7' => true,
    'level_6' => true,
    'level_5' => true,
    'level_4' => true,
    'level_3' => true,
    'level_2' => true,
    'level_1' => true,
    'level_0' => true,
    'edit_others_pages' => true,
    'edit_published_pages' => true,
    'publish_pages' => true,
    'delete_pages' => true,
    'delete_others_pages' => true,
    'delete_published_pages' => true,
    'delete_posts' => true,
    'delete_others_posts' => true,
    'delete_published_posts' => true,
    'delete_private_posts' => true,
    'edit_private_posts' => true,
    'read_private_posts' => true,
    'delete_private_pages' => true,
    'edit_private_pages' => true,
    'read_private_pages' => true,
  ),
))

#2 @ourakland
5 weeks ago

After trying different capabilities, I narrowed it down to edit_others_posts. If I add that to the author role, $_POST comes through unscathed to my save meta data function, and things work as as desired.

Of course, that causes a bunch of other problems (like authors being able to edit others' posts), but maybe can help narrow down where the problem is in the WP code.

Note: See TracTickets for help on using tickets.