简体   繁体   English

如何在 WordPress 中构建“用户组”访问控制?

[英]How can I build "user group" access control into WordPress?

WordPress has some lovely features for storing revisions, editor approval of content, etc. WordPress 有一些可爱的功能,用于存储修订、编辑人员批准内容等。

I'd like to expand on them by creating the concept of a user group/organisation .我想通过创建用户组/组织的概念来扩展它们。

I want:我想要:

  • to be able to attach posts to an organisation能够将帖子附加到组织
  • to be able to attach users to an organisation (and ideally make it so that users can invite other users to their same org)能够将用户附加到一个组织(理想情况下,使用户可以邀请其他用户加入他们的同一个组织)
  • users can only make changes to posts in the same org as them, everything else is read only.用户只能对与他们在同一组织中的帖子进行更改,其他所有内容都是只读的。

I can do the first two with a custom post type and an Advanced Custom Fields post object field , but I'm stumbling on the last one and would appreciate some pointers.我可以使用自定义帖子类型和高级自定义字段帖子对象字段来完成前两个,但我在最后一个上绊倒并希望得到一些指示。

I imagine I would need to create a custom role with add_role() , but I'm not sure what capabilities it should have.我想我需要使用add_role()创建自定义角色,但我不确定它应该具有哪些功能。

I imagine I'll need to override a hook somewhere to check if the thing the user is trying to edit is in their org.我想我需要在某处覆盖一个钩子来检查用户试图编辑的东西是否在他们的组织中。

Only relevant code so far is:到目前为止,只有相关的代码是:

register_post_type("organisation");

First, on WordPress, the default user system is: admin can do everything, editors can edit every post, authors can only edit their posts.首先,在 WordPress 上,默认的用户系统是:管理员可以做任何事情,编辑可以编辑每个帖子,作者只能编辑他们的帖子。

There are some plugins like https://es.wordpress.org/plugins/user-role-editor/ that may be useful for your needs.有一些插件,如https://es.wordpress.org/plugins/user-role-editor/ ,可能对您的需求有用。 Have a look at that!看看那个!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM