edit_comment
Fires immediately after a comment has been updated in the database.
Usage
function action_function_name_11( $comment_ID ) {
// Action...
}
add_action( 'edit_comment', 'action_function_name_11' );
Parameters
- $comment_ID(integer)
- The comment ID.
Examples
#1 Add an additional comment field when a comment is updated
Suppose we need to know whether a comment has been updated. When the comment is updated, we can write an additional updated field containing the update date.
add_action( 'edit_comment', 'add_update_comment_meta' );
function add_update_comment_meta( $comment_id ){
$comment = get_comment( $comment_id );
// Make sure we are editing an already published comment
if( ! $comment->comment_approved || $comment->comment_type !== 'comment' ){
return;
}
$data = time(); // Date in UNIX format
update_comment_meta( $comment_id, 'updated', $data );
}Changelog
| Since 1.2.0 | Introduced. |
| Since 4.6.0 | Added the $data parameter. |
Where the hook is called
wp-includes/comment.php 3014
do_action( 'edit_comment', $comment_id, $data );