Skip Navigation

[Resolved] Pre-select both parent and child in a many to many relationship form

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

Problem:

I setup a booking system by post relationship. I have Traders and Markets, I created a relationship Booking to connect them and store the booking info in the intermediate CPT.

The set up seems to work fine but I need two more things:

1) I need to send an email notification to the Trader's author when he books a market. I don't see the notification option on Relationship forms...

2) When a user login, I show him his Trader post (each user has only one) in a View loop and the complete list of markets (a sub-View loop) with a booking button on each market. When I click the button I want to display a form with Trader and Market preselected.

Solution:

Both of them are not available within Toolset form plugin, the client solved it by using a common post form:

https://toolset.com/forums/topic/pre-select-both-parent-and-child-in-a-many-to-many-relationship-form/#post-1135430

Relevant Documentation:

https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

This support ticket is created 6 years, 1 month 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 4 replies, has 2 voices.

Last updated by umbertoZ 6 years ago.

Assisted by: Luo Yang.

Author
Posts
#1134386

Hi, I setup a booking system by post relationship. I have Traders and Markets, I created a relationship Booking to connect them and store the booking info in the intermediate CPT.

The set up seems to work fine but I need two more things:

1) I need to send an email notification to the Trader's author when he books a market. I don't see the notification option on Relationship forms...

2) When a user login, I show him his Trader post (each user has only one) in a View loop and the complete list of markets (a sub-View loop) with a booking button on each market. When I click the button I want to display a form with Trader and Market preselected. I found I can create this links:

[cred-relationship-form-link content_template_slug="book-a-stall" form='book-a-stall' child_item='$current']
BOOK
[/cred-relationship-form-link]

[cred-relationship-form-link content_template_slug="book-a-stall" form='book-a-stall'  parent_item='[wpv-attribute name="trader"]']
BOOK
[/cred-relationship-form-link]

What I need should be this:

[cred-relationship-form-link content_template_slug="book-a-stall" form='book-a-stall' child_item='$current'  parent_item='[wpv-attribute name="trader"]']
BOOK
[/cred-relationship-form-link]

But it doesn't work. How can I do it?

Is there a way to add Parent/child shortcodes on Post Forms just like in the past?

I found this, but maybe is not updated:

https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

Thanks

#1134878

Hi,

Q1) I need to send an email notification to the Trader's author when he books a market. I don't see the notification option on Relationship forms...
You are right, there isn't "notification" option in relationship form, it needs a feature request, our developers will evaluate it.

Q2) When I click the button I want to display a form with Trader and Market preselected
Yes, it is expected result, you can only pre-select only one side, there isn't such kind of feature to pre-select two side, same as above, it needs a feature request, our developers will evaluate it

#1134881

Hi, both of them are very important features, they are things we can do with old Types and CRED versions. Isn't there a custom code workaround?

thanks

#1134901

There does exist a workaround by changing post type structure, for example:
1) You can create two one-to-many relationships between:
- Trader and intermediate CPT
- Market and intermediate CPT

2) Setup a post form for creating intermediate CPT, then you will be able to pre-select it's parent Trader post and Market post, see the document you mentioned above:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

For sending the email to "Trader" post author, you can use filter hook "cred_notification_recipients", see similar thread:
https://toolset.com/forums/topic/populate-child-post-title-with-parent-post-title/#post-908981

More help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

#1135430

My issue is resolved now. Thank you!

Finally I didn't need to use the filter hook "cred_notification_recipients" because I setup a common Post form with email notifications.

thanks