Hello. I have an issue with wp_new_comment and update_field.
I am using it in this form:
On submit I call this function:
function submit_comment() {
$data = $_POST;
print_r($data);
$commentdata = array(
'comment_post_ID' => $data['post_id'],
'comment_content' => $data['comment_text'],
'comment_type' => 'comment',
'user_ID' => $data['user_id'],
);
$new_comment = wp_new_comment( $commentdata );
if($new_comment && !empty($data['rating'])) {
foreach ($data['rating'] as $key => $value) {
echo $key.' '.$value.' '.$new_comment.'';
update_field($key,$value,'comment_'.$new_comment);
}
}
die;
}
as you can see everything is passing and printing from my rating fields:
the names of the fields are the same as in the comment form backend:
but somehow I get updated only these two fields:
I would understand if they were updated randomly, but WHY only these two fields? What’s wrong with the others?
When I tried to use a WP standard comment_form function with acf uncluded, everything was updated.
May be the function has to have a sort of timeout so the update_field functions doesn’t stop?