Problem:
Add a condition in Cred save data function to check the radio button:
if it is set on "approve", then I update the post status from "1" to "2"
if it is set on "refuse", then I update the post status from "1" to "0"
Solution:
Please add this code in your theme’s or child theme’s functions.php file:
add_action('cred_save_data', 'prefix_cred_save_data', 10, 2); function prefix_cred_save_data( $post_id, $form_data ){ if ($form_data['id']==1158){ //do the following code only if the CRED form ID is 1158, adjust this to your CRED form ID if(isset($_POST['my-generic-field']) && $_POST['my-generic-field'] != '') { // If generic value is set $generic_field_value = $_POST['my-generic-field'] == 'approve' ? 1 : 0; // if generic value is approve then return 1 otherwise 0 } else { $generic_field_value = 2; // If generic value is not set } update_post_meta($post_id, 'wpcf-etat-de-la-demande', $generic_field_value, true); // update custom field } }
==> Look for the comments in the above code and change your Form ID, Custom Field slug, etc as needed.
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 |
---|---|---|---|---|---|---|
- | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | - |
- | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | - |
Supporter timezone: Asia/Karachi (GMT+05:00)
This topic contains 2 replies, has 2 voices.
Last updated by 7 years, 3 months ago.
Assisted by: Noman.