Skip Navigation

[Resolved] Auto fill parent field in CRED form

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.03 hours from now. Thank you for your understanding.

This topic contains 18 replies, has 5 voices.

Last updated by Joff 7 years, 2 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#249270

Hi Pawel,

I have setup a testing site.
Can you please enable the form to send you access credentials?

Thanks
Carlo

Also one more thing: after your site theme refresh I don't receive animore email updates on support topics. I've checked the "Notify me of follow-up replies via email" checkbox but no more updates are coming.
Thanks

#249635

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (įŽ€äŊ“中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi Carlo,

I just take over this ticket, and the WordPress access details is not valid,
I assume you need a hidden field in the CRED form for create a child review post, which stores the parent movie post ID,

You can try below two option:
A) put your CRED form in another page, add a "Create Child Content link" in your movie content template, and enable the option "Set the parent according to the currently displayed content"
See the document:
Forms for the Currently Displayed Parents
https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

B) if you display the CRED form in the the parent movie post, you can try create a shortcode to get the current movie post ID, for example:
1) add codes in your theme/functions.php:

add_shortcode('current-parent-id', 'current_parent_id_func');
function current_parent_id_func($atts, $content){
	$queried_object = get_queried_object();
	return $queried_object->ID;
}

2) add a hidden Generic Fields in your CRED form:
for example:
[cred_generic_field field="_wpcf_belongs_movie_id" type="hidden" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[current-parent-id]"
}
[/cred_generic_field]

Please replace "movie" with the slug of your post type "movie"

#249815

Hi Luo,

that's exactly what I was looking for!

Thank you.
I hope you could add to your to-do-list the option "set as parent the post this cred form is inserted in" for CRED forms.

It could be really useful at least for me 😀

I'd like to thank even Pawel for his great support.

Best regards
Carlo

#320324

If it helps anyone down the track, I was just wanting to pull the parent title into my form. I have the form shortcode within the page.

I slightly modified the code to suit

//Shortcode to get current page as parent (for CRED form relationships)
add_shortcode('current-parent-id', 'current_parent_id_func');
function current_parent_id_func($atts, $content){
    $queried_object = get_queried_object();
    $title = get_the_title($queried_object);
    return $title;
}

Now the [current-parent-id] shortcode provides the parent title. As get_queried_object returns the current post, this could be modified to extract any post data really.