I have introduced a custom field in comments form using add_comment_meta() function.
I would like to know if there is a way to edit the data of the comment meta just before the post data is saved so that every time the data is replaced with my value before it is saved.
Lets say that the key is brand_id
.
I have used the following function to edit the custom_meta
Value
function update_comments_meta($post_id) {
$args = array(
'post_id' => $post_id,
);
$comments = get_comments($args);
if (!empty($comments)) {
foreach ($comments as $comment) {
echo $comment;
update_comment_meta($comment->comment_ID, 'brand_id', 'hard_coder');
}
}
}
add_action('save_post', 'update_comments_meta');
brand_id
comment meta values, related to a given post, each time that post is updated?