Hello,
I have 3 CRED forms, the first one creates the post, and the 2 other edit the post.
On each CRED form submission, I need to update the "status" of the post, which is a value between 0 to 6.
The first form and function update the custom field from "" to "1" ;
The second form and function update the custom field from "1" to "2" ;
But the third form and function don't update the custom field ! It stays "1" !!
The 3 functions are exactly the same :
add_action('cred_save_data', 'sauver_etat_commande_niv1',10,2);
function sauver_etat_commande_niv1($post_id, $form_data)
{if ($form_data['id']==197) {
error_log($form_data['id'] . $post_id . 'wpcf-etat-de-la-demande' . '1');
update_post_meta($post_id, 'wpcf-etat-de-la-demande', '1', true);}
}
add_action('cred_save_data', 'sauver_etat_commande_niv2',10,2);
function sauver_etat_commande_niv2($post_id, $form_data)
{if ($form_data['id']==266) {
error_log($form_data['id'] . $post_id . 'wpcf-etat-de-la-demande' . '2');
update_post_meta($post_id, 'wpcf-etat-de-la-demande', '2', true);}
}
add_action('cred_save_data', 'sauver_etat_commande_niv3',10,2);
function sauver_etat_commande_niv3($post_id, $form_data)
{if ($form_data['id']==291) {
error_log($form_data['id'] . $post_id . 'wpcf-etat-de-la-demande' . '3');
update_post_meta($post_id, 'wpcf-etat-de-la-demande', '3', true);}
}
Is there some kind of limitation with usage of cred save data ? Or what am I missing here ?!
Thank you.
Hi, first I would try to remove the 4th parameter, 'true', from each of your update_post_meta calls.
update_post_meta($post_id, 'wpcf-etat-de-la-demande', '1');}
...
update_post_meta($post_id, 'wpcf-etat-de-la-demande', '2');}
...
update_post_meta($post_id, 'wpcf-etat-de-la-demande', '3');}
From the docs at WordPress:
$prev_value
(mixed) (optional) The old value of the custom field you wish to change.
I don't think you should include "true" here. If this doesn't resolve the problem, please copy + paste the latest contents of your error log file here.
Fast and right into it. Great support. Thank you.