Dear Sir/Madam,
I have a form containing parent and child relationships, below is the field I link to the parent
<div class="form-group parent">
<label for="%%FORM_ID%%_@application-contestant.parent"></label>
[cred_field field='@application-contestant.parent' class='form-control' output='bootstrap' select_text='--- not set ---' required='true']
</div>
How I get the parent id when saving the form data, I want to rename the post title as Application XXX ( YYYY ) while XXX is the parent post id and YYY is current post id.
function my_save_data_action($post_id, $form_data)
{
if ( $form_data['id'] == 2571 ) {
$parent_id = ???????;
wp_update_post( array(
'ID' => $post_id,
'post_name' => $post_id,
'post_title' => sprintf("%s - %s (%s)", 'Application', $parent_id, $post_id)
));
}
}
add_action('cred_save_data', 'my_save_data_action',10,2);

Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Kelvin,
To get the Parent ID from the form you can try doing this.
$_POST["application-contestant_parent"]
If that doesn't work try this one below.
$_POST["application-contestant-parent"]
Thanks,
Shane

Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Kelvin,
Would you mind providing me with a link to the page where the form is so that I can check the payload of the Post request to get the correct field name.
Thanks,
Shane
You have to login with specific role
As this is not private message, could you remove this after testing?

Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Kelvin,
You're setting the parent based on a parameter in the URL correct.
If so then you can simply do this.
$_GET["parent_vwcm-application_id"]
This will get the parent ID for you from the URL.
Thanks,
Shane

Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Kelvin,
Great happy you were able to find a solution on our forums.
If there are no further queries then you can go ahead and mark this ticket as resolved.
Thanks,
Shane
My issue is resolved now. Thank you!