[wp-trac] [WordPress Trac] #56479: Missing capability shows blank page in WP-Admin

WordPress Trac noreply at wordpress.org
Wed Aug 31 16:34:07 UTC 2022


#56479: Missing capability shows blank page in WP-Admin
--------------------------------+-----------------------------
 Reporter:  vincenz17           |      Owner:  (none)
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Posts, Post Types   |    Version:  6.0.2
 Severity:  normal              |   Keywords:
  Focuses:  ui, administration  |
--------------------------------+-----------------------------
 Hello,

 I have created a **custom post type** with the following code.

 {{{#!php
 <?php
 function customPostTypeIBF()
 {
         $labels = array
         (
                 'name'                  => _x('Fortbildungen', 'Post Type
 General Name', 'ibf'),
                 'singular_name'         => _x('Fortbildung', 'Post Type
 Singular Name', 'ibf'),
                 'menu_name'             => __('IBF', 'ibf'),
                 'name_admin_bar'        => __('IBF-Fortbildung', 'ibf'),
                 'archives'              => __('IBF-Archiv', 'ibf'),
                 'all_items'             => __('Alle Fortbildungen',
 'ibf'),
                 'add_new_item'          => __('Neue Fortbildung', 'ibf'),
                 'add_new'               => __('Neue Fortbildung', 'ibf'),
                 'new_item'              => __('Neue Fortbildung', 'ibf'),
                 'edit_item'             => __('Fortbildung bearbeiten',
 'ibf'),
                 'update_item'           => __('Fortbildung speichern',
 'ibf'),
                 'view_item'             => __('Fortbildung anzeigen',
 'ibf'),
                 'view_items'            => __('Fortbildungen anzeigen',
 'ibf'),
                 'search_items'          => __('Fortbildung suchen',
 'ibf'),
         );

         $args = array
         (
                 'label'                 => __('IBF', 'ibf'),
                 'description'           => __('Fortbildungen verwalten',
 'ibf'),
                 'labels'                => $labels,
                 'supports'              => array('title', 'editor',
 'author', 'thumbnail', 'revisions', 'custom-fields'),
                 'show_in_rest'          => true,
                 'hierarchical'          => false,
                 'public'                => true,
                 'show_in_menu'          => true,
                 'menu_position'         => 5,
                 'menu_icon'             => 'dashicons-welcome-learn-more',
                 'has_archive'           => true,
                 'rewrite'               => array('slug' => 'ibf'),
                 'capability_type'       => 'post',
                 'capabilities'          => array
                 (
                         'edit_post'             => 'edit_ibf',
                         'edit_posts'            => 'edit_ibfs',
                         'edit_others_posts'     => 'edit_others_ibf',
                         'publish_posts'         => 'publish_ibf',
                         'read_post'             => 'read_ibf',
                         'read_private_posts'    => 'read_private_ibf',
                         'delete_post'           => 'delete_ibf',
                         'create_posts'          => 'create_ibfs',
                 ),
         );

         register_post_type('ibf', $args);
 }
 add_action('init', 'customPostTypeIBF', 0);
 }}}


 Then I adjusted the **wp_user_roles** field in the database so that the
 permissions are also set appropriately based on the role.


 Now when I don't have the **create_ibf** permission I get the following
 message in the admin panel:

 [[Image(https://i.ibb.co/2dPcrWh/error-ok.png)]]

 Thats right and it works!

 **Now the problem:** When I don't have the **edit_ibf** ''(without S at
 the end)'' permission I just get a white page (blank page) in the admin
 panel. Now error message or so. Only a white page. The source code shows
 the page but in the browser I cant see anything.
 If I use the developer tools I get the following error message:

 [[Image(https://i.ibb.co/gjjyhkZ/error-white.png)]]

 If I follow the link in the error message I can see that:

 [[Image(https://i.ibb.co/3dFQ8Sh/wp-rest-error.png)]]

 So I think here is a error message missing.

 **And now another funny thing:** When I havent the permission **edit_ibf**
 and disable the **block editor** with the parameter:
 {{{#!php
 <?php
 'show_in_rest' => false,
 }}}

 the page is loading:

 [[Image(https://i.ibb.co/dGJPdj3/ibf-ohne-blockeditor.png)]]


 I think something is wrong here. Maybe someone can take a look and fix
 this. At least the error message that you don't have enough rights would
 make sense, since you're looking for the error for a long time.

 Thanks in advance!

 **My Live-Server:** Ubuntu 20.04.3 with PHP 8.0.22 and MariaDB 10.5
 **My Test-Server (used here for reporting):** Windows 11 with XAMPP and
 PHP 8.0.19 and a fresh install from 18:00 Uhr

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56479>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list