Opened 12 years ago
Closed 12 years ago
#21463 closed enhancement (duplicate)
add create_posts capability
Reported by: | eternalsword | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4.1 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
1) Users without publish capability see Add New links even though they can't access post-new.php
2) Users require 'edit_posts' permissions to view editing area for custom post type with capability_type of $post_type even though they have "edit_{$post_type}s" capability.
I have a patch which resolves both issues. Let me know if I should break apart into two bugs/patches.
Attachments (1)
Change History (8)
#2
@
12 years ago
Did you create that patch against trunk or 3.4.1? It doesn't seem to apply cleanly against [21419]
#3
@
12 years ago
Also just at a glance, requiring the publish_posts
capability for being able to access the Add New page is incorrect. As long as they have edit_posts
(i.e. Contributors) they can access the page.
#4
@
12 years ago
It was against 3.4.1. I need to adjust the patch anyways. Will do so against trunk. I forgot there was the option for saving drafts on new posts. Perhaps there should be an additional default capabilty called create_post?
#5
@
12 years ago
- Summary changed from capability inconsistency to add create_posts capability
- Type changed from defect (bug) to enhancement
Okay, managed a few minutes today to take a fresh look. All my issues were caused by trying to remove the Add New menu item from my custom post prior to any changes I made to Wordpress code. In the admin_menu hook, I used
unset($submenu['edit.php?post_type=my_post_type'][10]);
to remove it. This is what caused item 2 since initially the submenu had two items and was reduced to one item which was removed because it was the same as its $parent thus leading to an inconsistent state of $submenu. Having a create_post capability in place would resolve this. Item 1 is invalid.
I'm changing the summary and marking this as an enhancement request.
The create_posts capability would be used to determine if someone has the ability to Add New.
#6
@
12 years ago
I replaced the initial patch since it had errors and wasn't the correct approach. The current patch adds the create_posts capability and checks for that instead of edit_posts in post-new.php. It additionally checks for that capability prior to putting in the Add New links.
get_admin_page_parent was also modified for the case where there is no $submenu.
This patch was also created against trunk instead of 3.4.1.
On second thought, I don't think item 2 is custom post type specific. I believe it would happen for normal posts in the event the user only has read_post and edit_posts. I won't be able to test until Monday.