最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Remove add post for user role

programmeradmin0浏览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 ?

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
Add a comment  | 

1 Answer 1

Reset to default 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/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 )

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论