Permissions with custom post types
-
Good day,
When attempting to duplicate a custom post type, the plugin only checks if the user can edit posts in general rather than the specific post type of the post.
For example, I have a WordPress site that has an “events” post type. By default, my permissions are configured so a user with a specific role has access to all “events” capabilities, such as “edit_others_events” or “publish_events”, etc. But they don’t by default have the “edit_others_posts” capability because they shouldn’t have the ability to edit another person’s posts, only their event. Without this capability (or any of the other checks in lines 121-129 being satisfied), the post won’t be duplicated.
What I think should happen is if the ‘edit_others_{post_type}’ capability is present, or if the ‘edit_{post_type}’ capability is present and the current user is the post’s author, that should be enough for duplication to succeed. I haven’t done a ton of testing, but I think the get_post_type_capabilties() function would work great for this: https://developer.ww.wp.xz.cn/reference/functions/get_post_type_capabilities/. If no custom post type capabilities are set, then the regular ‘edit_others_posts’ and ‘edit_posts’ capabilities could be used as a fallback.
The topic ‘Permissions with custom post types’ is closed to new replies.