Tell us what you are trying to do?
Create a post and then connect the relationship to the parent. (one to many)
The problem I am encountering:
I have created a function that creates the post and connection.
How do I obtain the parent and child post id's for the relationship connection.
The parent is the current logged in user and creator of the post.
The new form post is the child.
=======
/** Create new Hire-Proposal */
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
if ($form_data['id']==1111)
{
$my_post = array(
'post_title' => $_POST['post_title'],
'meta_input' => array(
'wpcf-cp-mem-id' => $post_id.$user_ID,
'wpcf-cp-mem-id-ref' => 'LC'. $post_id.$user_ID . 'CP2',
'wpcf-first-name1' => $_POST['first-name1'],
'wpcf-last-name1' => $_POST['last-name1'],
'wpcf-service-address' => $_POST['service-address'],
'wpcf-service-postcode' => $_POST['service-postcode']
),
'post_content' => 'xx',
'post_status' => 'publish',
'post_author' => $post_id,
'post_type' => 'csh-proposal-to-hire'
);
wp_insert_post( $my_post );
>>>>>> $parent_author_id = get_post_field ('post_author', $parent_post_id);
>>>>>> $child_ph_id = post_id;
toolset_connect_posts( 'seeker-proposal-to-hire-link', $parent_author_id, $child_ph_id )
}
}
Hello,
Since it is a custom PHP codes problem, please elaborate the question with more details:
1) How do you setup the post form?
2) How do you setup the custom field "post_author"?
3) How do you setup the relationship "seeker-proposal-to-hire-link"?
My issue is resolved now. Thank you!