0

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 ?

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
    Oct 22 '20 at 19:33
0

This 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.org/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 )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.