[Resolved] Select parent field using generic form generic select and connect parent

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.

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

Problem: How to assign parent post while creating child post using CRED generic field.

Solution: Using CRED hook: cred_save_data you can save the generic field "_wpcf_belongs_schools_id" value.

You can find the proposed solution with the following URL: => https://toolset.com/forums/topic/select-parent-field-using-generic-form-select/#post-526080

Relevant Documentation: => https://toolset.com/documentation/programmer-reference/cred-api/#csd

Related documentation: CRED Forms for Child Content

This topic contains 2 replies, has 2 voices, and was last updated by  Greig Neilson 11 months, 1 week ago. The support staff assigned to this topic is Minesh.

Viewing 3 posts - 1 through 3 (of 3 total)

I have a CRED form that I'm using to create a post and in doing select a parent. The child post is an Application and the parent post is a School.

The form field relies on a view which selects the post_id and the school name from another CPT. I know these are working because I can display them on the form the post id and name are correct.

Here's my code to select the parent:

[cred_generic_field field="_wpcf_belongs_schools_id" type="select" class="" urlparam="" value=""]
"options":[[wpv-view name="select-enrolment-schools"]]

The post saves correctly but fails to establish a relationship to the parent.

Thanks in advance for your help 🙂


Forum moderator

Supporter languages: English (English )

Supporter Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you need to use CRED hook: cred_save_data to save the generic field "_wpcf_belongs_schools_id" value.

You need to use WP standard function update_post_meta. For example:

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
    // if a specific form
    if ($form_data['id']==9999)
        if (isset($_POST['my_custom_field']))

           $school_id = $_POST['_wpcf_belongs_schools_id'];
            // add it to saved post meta
            update_post_meta($post_id, '_wpcf_belongs_schools_id',$school_id);

- Replace 9999 with your original CRED form ID.

More info:
=> https://toolset.com/documentation/programmer-reference/cred-api/#csd


Worked perfectly, thanks Minesh 🙂

Viewing 3 posts - 1 through 3 (of 3 total)