Skip Navigation

[Resolved] Create child post using current post as parent

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

Problem: I would like to show a Form that allows Users to create a child post, using the current post as the parent.

Solution: In a Form that creates the child posts, you should have a parent select field. If not, add the field or regenerate the form contents. If you do not want to display the field to your Users, use CSS to hide the field. Then set the value of the field using the current post's ID.

<div style="display:none;">
[cred_field field='@book-chapter.parent' select_text='--- not set ---' class='form-control' output='bootstrap' value="[wpv-post-id id='$current_page']"]
</div>

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

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

Our next available supporter will start replying to tickets in about 0.68 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#905430

Tell us what you are trying to do? Hello, could you help me with my next problem?
On my website hidden link, I have a CRED form "Add new document attached (ID: 37120)" that uploads attachments in a Type call "Complaints". What I want to do is that when they see a type "Denucia" and want to add a document this tells me what is its origin, to which "Complaint belongs"
The most I could do is show the number in the frontend, but I do not get information about which is the father of the document.
  [cred_post_parent get = 'id']
[cred_post_parent get = 'title']

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site? hidden link

hidden link

#905716
Screen Shot 2018-05-29 at 1.58.03 PM.png

Hi, it sounds like you want to display information about the parent Complaints post inside the Denuncia post. In that case, do not use the cred_post_parent shortcode. Use the Fields and Views button to insert a Post Title shortcode, and in the popup configuration window you can use the Post Selection tab to specify which post you want to display.

#905901
image2.png
image1.png

Not really
When someone makes a report, I have prepared that they can see it and it works perfectly. (image1.png). You can see that the files belonging to that complaint are perfectly seen in each complaint, data and images.
Then, they have the possibility to add more attachments. (image2.png)
They already have their complaint created. They can add more attachments, but once they add a document, I do not know to whom each new file belongs.
I have created a normal form, how to link it to their relationship?

#906161

In your Toolset Form, there should be a parent post select field. If not, you can add one by clicking "Add Post Fields" above the form editor. If you do not want to display this field to the end user, wrap it in a hidden div element. Use the "value" attribute to set the parent post ID to be the ID of the current page. Here is an example:

<div style="display:none;">
[cred_field field='@book-chapter.parent' select_text='--- not set ---' class='form-control' output='bootstrap' value="[wpv-post-id id='$current_page']"]
</div>

The last part with value="[wpv-post-id id='$current_page']" is what you will copy into your parent post field. The other code in the field will be different depending on your post type slugs and whether or not you're using the latest versions of Toolset Forms and whether or not the relationship was migrated.