AnsPress_Hooks::publish_comment( object|array $comment )
Description #
Actions to run after posting a comment
Parameters #
- $commentobject | array (Required) Comment object.
Source #
File: includes/hooks.php
public static function publish_comment( $comment ) {
$comment = (object) $comment;
$post = ap_get_post( $comment->comment_post_ID );
if ( ! in_array( $post->post_type, [ 'question', 'answer' ], true ) ) {
return false;
}
$count = get_comment_count( $comment->comment_post_ID );
ap_insert_qameta( $comment->comment_post_ID, array(
'fields' => [ 'unapproved_comments' => $count['awaiting_moderation'] ],
'last_updated' => current_time( 'mysql' ),
) );
// Log to activity table.
ap_activity_add( array(
'q_id' => 'answer' === $post->post_type ? $post->post_parent: $post->ID,
'action' => 'new_c',
'a_id' => 'answer' === $post->post_type ? $post->ID: 0,
'c_id' => $comment->comment_ID,
'user_id' => $comment->user_id,
) );
}
Expand full source code Collapse full source code View on GitHub: includes/hooks.php:469
Add your comment