Skip Navigation

[Resolved] display parent info on create child post CRED form

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

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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 8 replies, has 2 voices.

Last updated by eliseD-2 7 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#413125

I am using a View to display a post, and including a link to credit a CHILD POST for that post. (I have already set up two CPTs, Test and Answer - where Answer is set up to be a child of Test.)

In the CRED form that creates the child post, I would like to display some of the information from the parent post. I am using this code:

[types field="question1" id="$test"][/types]

But it comes up empty. If I specify the exact post, like this:

[types field='question1' id='218'][/types]

It works. But I don't want have to specify the exact post, because it won't always be the same post I am using to create the child post.

I know that it works to display parent info in a CRED EDIT form ... is it not possible in a Create Child Post form?

I guess the post doesn't exist until the SUBMIT button is pressed, so does that mean it doesn't know what its Parent is yet? That doesn't make sense to me because I am specifically creating a Child Post - so the parent is known already, right? Why can't I display any parent information on the Cred form itself?

Any help would be greatly appreciated.

Thanks!

Elise

#413135

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Elise,

Thank you for contacting our support forum.

You are absolutely correct in your analysis of the issue. However the section about the post not having an ID as yet is particularly important.

Our Types shortcode displays the information of a parent post based on the current child post ID and then finds its parent through the use of the id parameter.

So with a child post form, though it is a child post To be created, their is no ID for that post to be created.

What is being passed into the shortcode by default is the ID of the current page where the Create form is inserted.

So the information would not display on a Create form and only the Edit form because the post does not yet exist in the Create form.

The post has to first exist. It works when you specify the direct ID of the parent because you are explicitly telling types which custom field information to display.

I hope this clear this up for you.
Thanks,
Shane

#413144

Thanks for your prompt reply! (so sorry that we are both working on the 4th of July!)

That makes perfect sense.

I'm trying to figure out a work-around... would it be possible to somehow create a child post that has none of the fields filled out - that submits itself - and immediately goes to another page where I would have a CRED EDIT form that can show the parent fields?

I know the post title is required - perhaps I could find a way to automatically load that with the logged in user's name.

That way - the front-end user could click to create a child post - and the child post would be created automatically and the user would be taken to CRED form that edits the post that was just created.

Does that sound possible? And if so ... any ideas about how I would do it?

Thanks!

Elise

#413146

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Elise,

I'm happy i could clarify.

Actually the only fields that can be used to display the parent information can be seen in the link below.

https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

Under the section " Information about Parent Pages"

These fields display particular information about the parent.

Please let me know if this helps.
Thanks,
Shane

#413156

Actually, I know I can get the fields I need while in a Cred EdIt form (using the id="$parent" parameter).

What I'm asking now is: would it be possible to have the front-end user click a link to create a child post - but instead of seeing the create CRED form, the post would be be made automatically (with only the title filled in with the name of the logged in user) and everything else blank - and then the user would be immediately directed to a Cred EDIT form for the exact same post?

Or - perhaps easier - could the front end user see the Cred add child post form and click submit to post it - and then be taken directly to a cred EDIT form for the post they just made? In other words - could I directly attach the submit button for the create-child-post form to the edit form for the same post? Is there some kind of php code that would do that for a specific cred form?

Thanks.

Elise

#413449

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Elise,

In response to you question.

Actually yes this is possible but it will take some amount of coding to achieve. The post will need to be created through the use of php and then the shortcode to edit the post will need to be added to the post upon creation as well.

Unfortunately due to the work required to achieve this, it would go out of the scope of our support forum.

What you can do is to get in touch with one of our certified partners as they can definitely assist you better with setting up the code to achieve this.
https://toolset.com/consultant/

Thanks,
Shane

#414351

I discovered that I can get the title I want with this code:

[cred_post_parent get='title']

But I'm having problems putting that info into a cred field. I tried this:

[cred_field field="post_title" post="answer" value="[cred_post_parent get='title']"]

But that doesn't display properly. What am I doing wrong?

Thanks!

Elise

#414551

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Elise,

I was also able to see this issue as well.

What you can do as a workaround is to replace you cred field with a generic one and add the shortcode to it.

Example

      [cred_generic_field field='post_title' type='textfield' class='' urlparam='']
{
"required":1,
"validate_format":0,
"default":"[cred_post_parent]"
}
[/cred_generic_field]

Please let me know if this helps.
Thanks,
Shane

#414622

That worked perfectly - thanks!

Elise

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.