[wp-trac] [WordPress Trac] #42323: Posts vs CPT user permissions issue

WordPress Trac noreply at wordpress.org
Tue Sep 23 10:48:26 UTC 2025


#42323: Posts vs CPT user permissions issue
-----------------------------+-----------------------------
 Reporter:  bor0             |       Owner:  (none)
     Type:  defect (bug)     |      Status:  closed
 Priority:  normal           |   Milestone:
Component:  Role/Capability  |     Version:  4.9
 Severity:  normal           |  Resolution:  worksforme
 Keywords:  has-patch        |     Focuses:  administration
-----------------------------+-----------------------------
Changes (by SirLouen):

 * keywords:  has-patch needs-unit-tests needs-testing => has-patch
 * resolution:   => worksforme
 * status:  assigned => closed
 * component:  Posts, Post Types => Role/Capability
 * milestone:  Awaiting Review =>


Comment:

 == Reproduction Report
 === Description
 ❌ This report can't validate that the issue can be reproduced.

 === Environment
 - WordPress: 6.9-alpha-60093-src
 - PHP: 8.2.29
 - Server: nginx/1.29.1
 - Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
 - Browser: Chrome 140.0.0.0
 - OS: Windows 10/11
 - Theme: Twenty Twenty-Five 1.3
 - MU Plugins: None activated
 - Plugins:
   * BBB Testing Dolly
   * Test Reports 1.2.0
   * User Switching 1.10.0

 === Testing Instructions
 1. Added the code in supp artifacts
 2. The idea is to have a new role called Limited, which happens to have
 caps to edit, create and publish a CPT called Test, but no extra caps to
 publish regular Posts as suggested by OP
 3. 👌 User can publish posts

 === Actual Results
 1. ❌ Error condition occurs (reproduced).

 === Additional Notes
 - I'm closing this as it's not reproducible anymore.

 === Supplemental Artifacts

 {{{#!php
 <?php
 add_action( 'init', function () {
         register_post_type( 'test', array(
                 'label' => 'Test',
                 'public' => true,
                 'show_in_rest' => true,
                 'capability_type' => array( 'test', 'tests' ),
                 'map_meta_cap' => true,
                 'supports' => array( 'title', 'editor' ),
         ) );
 } );

 register_activation_hook( __FILE__, function () {
         add_role( 'limited', 'Limited', array( 'read' => true ) );
         $role = get_role( 'limited' );
         if ( $role ) {
                 $role->add_cap( 'edit_tests' );
                 $role->add_cap( 'edit_test' );
                 $role->add_cap( 'create_tests' );
                 $role->add_cap( 'publish_tests' );
         }
 } );
 }}}

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


More information about the wp-trac mailing list