Skip Navigation

[Resolved] Connect multiple posts with a parent at one time using one form

This thread is resolved. Here is a description of the problem and solution.

Problem:

Many-to-many relationship between post typs "action items" and "weeks".

Connect multiple "action items" posts with one "weeks" post within one relationship form.

Solution:

One relationship form can handle only one relationship between "action items" post and "weeks" post, it needs custom codes, for example:

https://toolset.com/forums/topic/connect-multiple-posts-with-a-parent-at-one-time-using-one-form/#post-1380655

Relevant Documentation:

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

This support ticket is created 5 years, 2 months 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by Tyler 5 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1380423

***Tell us what you are trying to do?***
I have a post type called "action items" that is associate with two other post types: 90-day plans, and weeks. The idea is you list all the actions you want to take in the 90 days (so they are then associated with a given 90-day plan), then each week you select the action items you want to do in that week (and that would then associate them with the given week).

In summary I want to:
-List all the "action items" associated with a particular 90-day plan post item (I already know how to do this).
-Select several of them at a time (maybe with a check-box, for example).
-Click "Save" or "Submit" and create a new connection between all the selected "action items" and a certain week (probably chosen from a list/dropdown).

***Is there any documentation that you are following?***
I've read over this documentation (https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/) but it seems to only allow working with one post at a time also does not filter the posts the way I'm looking to.

***What is the link to your site?***
goals.brandoncollins.org

#1380655

Hello,

I assume we are talking about this case:
Three post types:
- 90-day plan
- action items
- weeks

Two post type relationships:
- One-to-many relationship between post types "90-day plan" and "action items"
- Many-to-many relationship between post typs "action items" and "weeks".

You are going to connect multiple "action items" posts with one "weeks" post within one relationship form.

If it is, there isn't such kind of built-in feature within Toolset Forms plugin.

One relationship form can handle only one relationship between "action items" post and "weeks" post.

After user Click "Save" button, pass those selected "action items" IDs value and certain week post ID as POST variables to WordPress, setup custom codes, catch those post IDs, setup the post type relationships with function toolset_connect_posts(), see our document:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
Connects posts within a given post relationship.

#1381599

That's helpful. I think the API is the right idea for what I'm looking for.