Problem: I have a Form that creates posts and allows the User to choose two post parents from other post types. I would like to use the Forms API to automatically set the child post title to include the title of both parent posts.
Solution:
Add this hook:
add_action('cred_save_data', 'your_save_data_action',10,2); function your_save_data_action($post_id, $form_data) { // if a specific form if ($form_data['id']==138) { $docyear = get_post_meta($post_id, 'wpcf-year', true); $custname = isset($_POST['@customer-requirement_parent']) ? get_the_title($_POST['@customer-requirement_parent']) : ''; $docname = isset($_POST['@document-master-list-requirement_parent']) ? get_the_title($_POST['@document-master-list-requirement_parent']) : ''; $drdetail= $docyear. ' - ' . $custname. ' - ' . $docname; $args = array('ID' => $post_id, 'post_title' => $drdetail); wp_update_post($args); } }
Relevant Documentation: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
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)
Ce sujet contient 2 réponses, a 2 voix.
Dernière mise à jour par Il y a 6 années.
Assisté par: Christian Cox.