Hello everyone,
Me and my team are working on a project and are facing problems implementing an access control mechanism.
Current Setup:
We have multiple Workgroups. Each of them have multiple Projects, where each of them can have multiple ProjectPosts.
Custom Post Types:
- Workgroup
- Project
- ProjectPost
Relationships
Workgroups [*] <<<>>> Projects [*]
Projects [0 .. 1] << ProjectPosts [*]
Tell us what you are trying to do?
Everyone can read Workgroups, Projects and ProjectPosts. The WorgroupAdmin creates a new Project and gives specific users the right to edit that specific project and to create new ProjectPosts which are related to that Project using a front-end form. Everyone of these users then also have the right to edit and delete ProjectPosts which are related to the Project they have editing rights on.
Our idea to solve the problem
For each Project create a PostGroup in Toolset Access. Add the Project to that PostGroup. Add specific users to that PostGroup and give them the right to edit the the Project.
Problem!
ProjectPosts create by someone in the Team (the users who have access to the project) needs to be automatically added to the PostGroup of that Project. Otherwise other users of the team don't have the right to edit ProjectPosts create by someone in the Team.
The Solution?
I thought about using a hook on the form where the ProjectPost gets created and then automatically added to the PostGroup the Project is in.
Note
The front-end form to create a new ProjectPost exists in a Popup which opens when clicking a button "Add ProjectPost" on the Project site.
Question
Is something like this possibly. Can I call Toolset Access Functions to add a ProjectPost to a PostGroup?
If not, is there another approach so solve this problem?
I really appreciate your help on this.
Have a great Day
Cheers
Michael
Hi, there is no built-in feature in Forms or Access that will automatically set an Access Post Group for new posts created by that Form, but it's possible to do something similar with a bit of custom code. The solution is described in another ticket, including some example code:
https://toolset.com/forums/topic/how-to-use-cred-post-form-to-set-post-group-for-new-cpt-post/#post-572829
Hello Christian,
First of all thank you for reaching out that fast.
That actually sounds like a solution. There is just one more thing.
The PostGroup for a project should be auto generated when creating a Project. Then every ProjectPost created using the form on the project-page should be added to the auto generated PostGroup of that Project.
Is there a way to auto generate PostGroups on form submission and if so can I then read out its id to add ProjectPosts ?
Thank you
Have a great one
Michael
Hello Michael,
I am afraid there is not an API to create programmatically new Access Post Groups.
I can escalate this to our 2nd Tier as a feature request if you would like so.
So, currently, you will need to rely on heavy custom coding to allow each ProjectPost to be seen and edited by the permitted users.