最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

custom post types - delete_published_posts does not work

matteradmin10PV0评论

I made a plugin with a custom post type calls "product". For some reasons, the administrator cannot move to trash post inside the list table.

I know the capability to do that is delete_published_posts. I checked all capabilities for the administrator on the right page like this :

$user = wp_get_current_user();
    pretty_var_dump( $user->allcaps );

array (
    'switch_themes' => true,
    'edit_themes' => true,
    'activate_plugins' => true,
    'edit_plugins' => true,
    'edit_users' => true,
    'edit_files' => true,
    'manage_options' => true,
    'moderate_comments' => true,
    'manage_categories' => true,
    'manage_links' => true,
    'upload_files' => true,
    'import' => true,
    'unfiltered_html' => true,
    'edit_posts' => true,
    'edit_others_posts' => true,
    'edit_published_posts' => true,
    'publish_posts' => true,
    'edit_pages' => true,
    'read' => true,
    'level_10' => true,
    'level_9' => true,
    'level_8' => 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,
    'delete_users' => true,
    'create_users' => true,
    'unfiltered_upload' => true,
    'edit_dashboard' => true,
    'update_plugins' => true,
    'delete_plugins' => true,
    'install_plugins' => true,
    'update_themes' => true,
    'install_themes' => true,
    'update_core' => true,
    'list_users' => true,
    'remove_users' => true,
    'promote_users' => true,
    'edit_theme_options' => true,
    'delete_themes' => true,
    'export' => true,
    'edit_product' => true,
    'read_product' => true,
    'delete_product' => true,
    'edit_products' => true,
    'edit_others_products' => true,
    'publish_products' => true,
    'read_private_products' => true,
    'create_products' => true,
    'edit_post' => true,
    'delete_private_products' => true,
    'delete_published_products' => true, //<-- ?!
    'delete_others_products' => true,
    'edit_private_products' => true,
    'edit_published_products' => true,
    'administrator' => true,
)

So, I don´t know why it does not work. Someone has got an idea ?

I made a plugin with a custom post type calls "product". For some reasons, the administrator cannot move to trash post inside the list table.

I know the capability to do that is delete_published_posts. I checked all capabilities for the administrator on the right page like this :

$user = wp_get_current_user();
    pretty_var_dump( $user->allcaps );

array (
    'switch_themes' => true,
    'edit_themes' => true,
    'activate_plugins' => true,
    'edit_plugins' => true,
    'edit_users' => true,
    'edit_files' => true,
    'manage_options' => true,
    'moderate_comments' => true,
    'manage_categories' => true,
    'manage_links' => true,
    'upload_files' => true,
    'import' => true,
    'unfiltered_html' => true,
    'edit_posts' => true,
    'edit_others_posts' => true,
    'edit_published_posts' => true,
    'publish_posts' => true,
    'edit_pages' => true,
    'read' => true,
    'level_10' => true,
    'level_9' => true,
    'level_8' => 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,
    'delete_users' => true,
    'create_users' => true,
    'unfiltered_upload' => true,
    'edit_dashboard' => true,
    'update_plugins' => true,
    'delete_plugins' => true,
    'install_plugins' => true,
    'update_themes' => true,
    'install_themes' => true,
    'update_core' => true,
    'list_users' => true,
    'remove_users' => true,
    'promote_users' => true,
    'edit_theme_options' => true,
    'delete_themes' => true,
    'export' => true,
    'edit_product' => true,
    'read_product' => true,
    'delete_product' => true,
    'edit_products' => true,
    'edit_others_products' => true,
    'publish_products' => true,
    'read_private_products' => true,
    'create_products' => true,
    'edit_post' => true,
    'delete_private_products' => true,
    'delete_published_products' => true, //<-- ?!
    'delete_others_products' => true,
    'edit_private_products' => true,
    'edit_published_products' => true,
    'administrator' => true,
)

So, I don´t know why it does not work. Someone has got an idea ?

Share Improve this question asked Jan 21, 2019 at 12:16 J.BizMaiJ.BizMai 9302 gold badges10 silver badges30 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

What I need to see was the posts were draft, I had to add the capabilty delete_posts.

Post a comment

comment list (0)

  1. No comments so far