Skip Navigation

[Resolved] automatically add created post using a specific Front-End Form to PostGroup

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 3 replies, has 3 voices.

Last updated by Jamal 3 years, 12 months ago.

Assisted by: Jamal.

Author
Posts
#1880943

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

#1881835

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

#1882293

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

#1886889

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.