Skip Navigation

[Resolved] Is there anyway to automatically set a post reference or relationship?

This support ticket is created 5 years, 3 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.

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by esmondR 5 years, 3 months ago.

Author
Posts
#1356177

Tell us what you are trying to do? I want to set the either a post reference, relationship or repeatable field group parent automatically, so that when i create a new custom post via a cred form that is linked to from another post type, the relationship is set.

Is there any documentation that you are following? I have tried URL parameters and also populating custom fields from gravity form entries.

Is there a similar example that we can see? Not sure.

What is the link to your site? - hidden link

#1356203
Bildschirmfoto 2019-10-05 um 16.50.15.png

Partially only, for post relationships, it should be possible, as shown here:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/#creating-forms-when-a-parent-post-is-preselected

You would insert a "create child form link" in the Content Template where you show the "parent" post.
It can be inserted using the "Forms" Button to insert forms, and it will ask you how to set the "parent" of the post that is going to be created by that form.
You can set it to be the current post, so clicking that link in the front end would lead to the Form to create or edit a related post, and have the post already set as the related one.

That works wherever you have a form in a relationship, but only in One To Many, not in Many To Many relationships, there the approach is different because you connect with a separate form and those do not listen to the same ShortCode attributes.
I have added a screenshot of the setting of the create child post link, which you will see when inserting it.
You can either use Set the parent according to the currently displayed content or Choose a specific parent.

You can also use custom code for more complex such automatizations, so for example you can hook into the save_post() or, if it's on the Front end with a Toolset Form, into the cred_save_data(), and pass your own logic to connect specific posts, using the Toolset Relationships API:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

There are also some other, custom solutions out there, using Toolset Forms for this:
hidden link
That's pretty fresh and updated, I see it as a valid, good solution for this, as well.
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/

I hope the first is what you need, as it will be the simplest 🙂

#1356817

My issue is resolved now. Thank you!