When a users submits a CF7 form I have a function hook that fires and does the saving to a custom template for the current form. However I want to update one field of another already existing custom post type (all created using acf).
I know the target post id as this is passed as a hidden field on the displayed form but this doesn’t work
$postfield = ‘post_status’;
$newvalue = ‘Submitted’;
update_post_meta( $postid, $postfield, $newvalue);
……but this does?
update_post_meta( 2147, $postfield, $newvalue);
If i pass the post id as a raw integer it works fine but if i try to pass it as a variable it just won’t write the update.
I’ve trawled posts and tried suggestions but can’t seem to find a fix. I have tried togling the REST Api on and off for the ACF fields, I have the target field set as a numeric and even tried forcing it to (int) before passing it just to be certain. Feel like I must be missing something really simple!
Stu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.