Yes, account, user, session are all post types. The relationships are both one to many. Each account can have many users and each user can have man sessions.
So I can simply css display none the field to pick the parent and I'm fine?
I have another question also. I would like to use the cred_save_data action to change the name of the session post.
I'd like to name the post the date, which is working, and then then data from custom fields in the parent.
Below you'll see I added wpcf-client-first-name. However I'm only the date i the post title. Do I need to call that data a different way?
Thank you
add_action('cred_save_data', 'my_save_data_action2',10,2);
function my_session_save_action($post_id, $form_data){
// Change your CRED Form "ID" accordingly below
if ($form_data['id']==28){
//Declare the content of your variables, change "your_custom_field_slug" accordingly
$first = get_post_meta( $post_id, 'wpcf-client-first-name', true );
$last = get_post_meta( $post_id, 'wpcf-client-last-name', true );
$date = get_post_meta( $post_id, 'wpcf-session-date', true );
$formated_date = date("M j y", ($date));
$custom_title = $formated_date.' '.$last.' '.$first;
//collect data and define new title
$my_post = array(
'ID' => $post_id,
'post_title' => $custom_title,
'post_name' => $custom_title,
);
// Update the post into the database
wp_update_post( $my_post );
}
}
add_action('cred_save_data', 'my_session_save_action',10,2);
For clarity on this you are able to get the date correctly ? This means that the date is being added to the post title correctly.
The issue is that you are not able to get the first and last name correct?
You stated here "However I'm only the date i the post title. Do I need to call that data a different way?"
The other fields you are referring to calling in a different way is the first and last name ? Are these fields on the same form being submitted ? or are they in a post relationship on another post type.
Please let me know.
Thanks,
Shane
The topic ‘[Closed] Split: Relationship Post’ is closed to new replies.