Skip Navigation

[Resolved] Cred post form (child) get custom fields from parent relationship post

This support ticket is created 2 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.

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: Africa/Casablanca (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by adamG-6 2 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#2185767

Tell us what you are trying to do?

I would like to pre populate certain fields in the child form using custom filed values from the parent post type.

Parent post type = Job
Child post type = Application

Is there any documentation that you are following?
No

Is there a similar example that we can see?
No

What is the link to your site?
hidden link

#2186045

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting Toolset support.

It seems that you are already setting the parent post using a URL parameter(parent_job_id=26), right?
If that's the case you can use it in the item attribute to get the value of the field, and directly pass it to the value of the field. For example:

[cred_field ..... value=[types field="the-field" item="[wpv-search-term param="parent_job_id"]"][/types]"]

- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-search-term
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
However, Toolset does not allow 3 levels of nested shortcodes. So, you will need to register your own shortcode to pass the value:

[cred_field .... value="[your-shortcode]"]

And register the shortcode with something like:

add_shortcode('your-shortcode', function(){
    $parent_id = do_shortcode('[wpv-search-term param="parent_job_id"]');
    return wpv_do_shortcode('[types field="the-field" item="' . $parent_id . '"][/types]');
});

Please note that I did not test the shortcode. It is meant to explain the idea to you. I hope it makes sense.

#2186733

Thank you for your help on this. It sort of worked but found it easier to embed the form into the job posts as opposed to linking to a new page.

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