Tell us what you are trying to do?
- I have a CRED form that connects existing parent post with a child post and it looks like this:
[credform]
<div class="form-group">
<label for="%%FORM_ID%%_@radiologist-to-report-request.parent">[cred_i18n name='@radiologist-to-report-request.parent-label']Radiologists[/cred_i18n]</label>
[cred_field field='@radiologist-to-report-request.parent' class='form-control radiologist-to-report-request-field' output='bootstrap' select_text='--- not set ---' required='false']
</div>
[cred_field field='form_messages' class='alert alert-warning']
[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
[/credform]
- I am using cred_save_data to get information from a parent post field='@radiologist-to-report-request.parent' in order to use it further to update a child post field.
The code looks like this:
add_action('cred_save_data', 'rad_order_toolset_associations_created',10,2);
function rad_order_toolset_associations_created( $post_id, $form_data )
{
if ( $form_data['id']==number )
{
$rad_post_id = $_POST['@radiologist-to-report-request.parent'];
error_log( "rad_post_info: " . $rad_post_id );
$rad_first_name = get_post_meta($rad_post_id, 'wpcf-radiologist-first-name', true);
$rad_last_name = get_post_meta($rad_post_id, 'wpcf-radiologist-last-name', true);
update_post_meta($post_id, 'wpcf-associated-radiologist-to-report-order-name', $rad_first_name . " " . $rad_last_name);
}
}
For some reason, I get nothing from the parent field ( $rad_post_id = $_POST['@radiologist-to-report-request.parent'];) Error log shows nothing from this field.
There is no PHP errors in logs and the form itself works ok (means that the parent post is getting connected to the child post).
Therefore I would like to ask you to point out what I am missing here.
Is there any documentation that you are following?
- Yes:
- - https://toolset.com/forums/topic/cannot-get-parent-child-post-meta-from-cred_save_data/
- -https://toolset.com/documentation/programmer-reference/cred-api/#cred_submit_complete
Is there a similar example that we can see?
- I can't find any ready working solution, sorry.
What is the link to your site?
- hidden link