Problem: I am using CRED to create child posts. I would like to programmatically set the child post title based on the parent post title. I'm using the beta plugins.
Solution:
The post data key for accessing the parent post's ID has changed in the M2M betas. You can now use the format "@" + relationshipslug + "_parent". In this case the relationship slug is member_visitation, so the key is "@member_visitation_parent".
add_action('cred_save_data', 'copy_parent_title_to_child',10,2); function copy_parent_title_to_child($post_id, $form_data) { // if a specific form if ($form_data['id']==429) { if (isset($_POST['@member_visitation_parent'])) { $my_post = array( 'ID' => $post_id, 'post_title' => get_the_title($_POST['@member_visitation_parent']) ); wp_update_post( $my_post ); } } }
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 13 replies, has 2 voices.
Last updated by 6 years, 7 months ago.
Assisted by: Christian Cox.
The forum ‘Types Community Support’ is closed to new topics and replies.