-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Image disappears only in Gutenberg with CPT #12198
Comments
Same here. I have an 'capability_type' => array('event','events'),
'capabilities' => array(
'read' => 'read_events',
'read_private_posts' => 'read_private_events',
'edit' => 'edit_events',
'edit_private_posts' => 'edit_private_events',
'edit_published_posts' => 'edit_published_events',
'edit_others_posts' => 'edit_others_events',
'publish' => 'publish_events',
'delete' => 'delete_events',
'delete_private_post' => 'delete_private_events',
'delete_published_post' => 'delete_published_events',
'delete_others_post' => 'delete_others_events',
),
'map_meta_cap' => true, and a custom role which has the following capabilities :
When I'm logged in as an administrator, I can edit the Featured Image in Gutenberg, but when I have the custom role, I can't. When I disable Gutenberg using the Classic Editor plugin, I can edit the Featured Image with the custom role. As mentionned, when I add Tested with WP 5.0.3. |
@designsimply Could you give a look at that? It looks like a bug. |
@ridesirat, I installed and activated the Members 2.10 plugin, but I'm still not quite sure how to do this part:
I installed & activated Jetpack 6.9 and Confit 1.3.3, but when I went to Users > Roles and created a new role I wasn't sure how to give access to just the CPTs (Confit+Jetpack has two CPTs: Testimonials & Food Menus). Would you mind walking me through testing steps for that part in a bit more detail? @benoitchantre I'll update the labels! I also did a quick search on core.trac and found a very similar (but very old!) ticket about featured images not working with CPTs and am adding a link to it here just in case it's helpful https://core.trac.wordpress.org/ticket/15779 (apologies if it's too old or too different to be useful). However, based on reading that issue and also noting that a similar issue was reported at #6919 and turned out to be a plugin conflict and not an issue with Gutenberg in that case. In 6919, they mention that updating to ACF Pro 5.6.10 fixed the issue and I tried checking the ACF plugin changelog for anything related but didn't spot anything. |
Same here. The Featured Image for CPT does not appear if the user has not the |
Hi @designsimply I don't know if your CPTs are showing. In order to show in "Edit Role" on the "Members" plugin I have I now came with a workaround for my problem: Leave |
I have the same issue as described by @benoitchantre and @ridesirat. I have a custom post type (cities) with custom capabilities. I also have a custom role ( As an admin, using Gutenberg (WP5.0.3 and/or plugin), I can see the featured image for my Cities CPT. As a When I check off the The only plugins I have on the site are Classic Editor, Gutenberg, User Role Editor, and the WordPress Importer. I've also switched to the twentynineteen theme and can confirm the issue is still there. |
@benoitchantre I'm a little bit out of my depth, I wasn't sure how to add your example, but I found https://codex.wordpress.org/Function_Reference/register_post_type#Example and added the elaborate example from there (and also I also noticed that nothing in the example from https://codex.wordpress.org/Function_Reference/register_post_type#Example didn't work if I added
I noticed that you didn't have |
@designsimply Sorry if my first comment didn't contained enough details. Here's something more detailed. You can create a file with the following code and place it in a cpt-capabilities-test.php <?php
/*
Plugin Name: Custom Post Type - capabalities test
Description: Register an event custom post type with custom capabilities
*/
function cpt_capabilities_test_register_post_type() {
$labels = array(
'name' => 'Events',
'singular_name' => 'Event',
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_rest' => true,
'capability_type' => array('event','events'),
'capabilities' => array(
'read' => 'read_events',
'read_private_posts' => 'read_private_events',
'edit' => 'edit_events',
'edit_private_posts' => 'edit_private_events',
'edit_published_posts' => 'edit_published_events',
'edit_others_posts' => 'edit_others_events',
'publish' => 'publish_events',
'delete' => 'delete_events',
'delete_private_post' => 'delete_private_events',
'delete_published_post' => 'delete_published_events',
'delete_others_post' => 'delete_others_events',
),
'map_meta_cap' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
);
register_post_type( 'event', $args );
}
add_action( 'init', 'cpt_capabilities_test_register_post_type' ); This will register a custom post type with the custom capabilities. As your user/role don't have these capabilities, nothing will show in your dashboard until you add them. To add them without code, I suggest you to use the Members plugin. When activated, you will be able to edit the capabilities under Users > Roles. To fully test the issue, you'll need a test user and a custom role. When logged in with you test user using this custom role, you should see the Event post type in the dashboard. You should also be able to create events and see that:
Now, if you check the Edit Posts capability, you'll see that the post thumbnails metabox reappears in the Block editor. You also get the ability to create posts (unwanted). The User Switching plugin will help you to quickly change the current user account. I hope it helps.
The |
Gah. I thought I was onto something there! 😁 I will try this test again soon using the extra details! Thanks for walking me through. 🙂 |
I run into exactly the same problem as described by @benoitchantre. Unless the |
I am having a same problem. |
I found the cause of this problem.
In this issue, we created a custom capability like |
I opened a ticket on Trac. |
If I'm understanding correctly, as the issue stems from the REST API implementation, Trac is the correct place to follow this issue, and it would immediately become resolved in Gutenberg as a result of a fix there (i.e. it is implemented correctly in Gutenberg). Thanks for debugging and following-up with the Trac ticket. |
I'm starting to test Gutenberg (4.5.1) in some clients web apps and this is a strange behavior:
I have 2 CPT ("Projects" and "News") and I'm not using the default "Posts" type (DPT).
I have created some User Roles in "Members" plugin with access to the 2 CPT only. They have "Edit Posts" disabled only in the DPT.
All working well but Featured image disappears (in Classic editor is ok). But It comes back on when you enable "Edit Posts" in the DPT type for those Roles.
I've tried turning on/off everything (I hope) in register_post_type() but never worked.
I only have these: 'supports' => array('title', 'thumbnail', 'editor', 'excerpt')
Desktop (please complete the following information):
I hope it helps.
The text was updated successfully, but these errors were encountered: