An action hook where a comment meta is updated

I think you only want get_comment and not get_comments on this line:

$com=get_comments($comment_id);

You are only checking for a single comment, by the ID. get_comments won’t do that the way you are using it.

There is a check halfway through the update_metadata function that compares the existing value to new value under some circumstances. That runs before the update_comment_meta hook and sometimes returns so that that hook never runs. Admittedly this is a guess, but if you are passing the same value, such as true every time this may be where it hangs.

The update_{$meta_type}_metadata hook would fire, but is a filter and not really the best choice for this kind of hook. I am wondering if you shouldn’t be using the edit_comment hook instead.

Leave a Comment