Problem: I would like to capture the value from a generic field using cred_save_data, and store it in a custom field.
Solution: Add the following code to functions.php:
add_action('cred_save_data', 'sauver_responsable_projet',10,2); function sauver_responsable_projet($post_id, $form_data) { // if a specific form if ($form_data['id']==87) { if (isset($_POST['responsable-projet'])) { update_post_meta($post_id, 'wpcf-responsable-projet', $_POST['responsable-projet'], true); } } }
Create a generic field called 'responsable-projet' in your CRED form, and create a custom field called 'responsable-projet' in the post type associated with the CRED form.
Relevant Documentation:
https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/
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)
This topic contains 18 replies, has 2 voices.
Last updated by 7 years, 3 months ago.
Assisted by: Christian Cox.