I add new role with WP Members, I also use Publishpress and user role editor For my new role, I want to disable the capability to create posts (built-in not custom post), not only with CSS but the entire capability. My custom role can only edit post I know it's possible, I already see that but I can't find how to do this.
I tried to remove_cap('create_post') but it doesn't work
Could you help me please ?
I add new role with WP Members, I also use Publishpress and user role editor For my new role, I want to disable the capability to create posts (built-in not custom post), not only with CSS but the entire capability. My custom role can only edit post I know it's possible, I already see that but I can't find how to do this.
I tried to remove_cap('create_post') but it doesn't work
Could you help me please ?
Share Improve this question asked Oct 22, 2020 at 17:55 user7734861user7734861 533 bronze badges 1- I have posted the answer to this question, but you've fallen into the trap of asking how to implement your solution, not how to solve your problem. If you had asked how to remove the add new UI or how to prevent users from creating posts at the database level, then there are solutions for that, but they do not involve capabilities. I recommend you ask a new question focused on your original problem – Tom J Nowell ♦ Commented Oct 22, 2020 at 19:33
1 Answer
Reset to default 0This is not possible using the capabilities system, the granularity you want does not exist in WP core:
edit_posts
- Since 2.0
- Allows access to Administration Screens options:
- Posts
- Posts > Add New
- Comments
- Comments > Awaiting Moderation
https://wordpress/support/article/roles-and-capabilities/#edit_posts
edit_posts
covers both viewing, adding, and editing posts, as well as commenting. There is a capability that controls wether you can edit other peoples posts however, but that isn't what you asked for.
Internally, the lowest abstraction before we get to raw SQL is wp_insert_post
, which handles both post creation, and post updating. The only difference between creating a post and editing a post is wether a post ID is in the array passed to wp_insert_post
( wp_update_post
is just a wrapper around wp_insert_post
)