Advertisements

wp_trash_comment

Definition:
function wp_trash_comment($comment_id) {}

Moves a comment to the Trash
If trash is disabled, comment is permanently deleted.

Parameters

  • int $comment_id: Comment ID.

Return values

returns:False on failure

Defined actions

  • trash_comment
    do_action('trash_comment', $comment_id);
  • trashed_comment
    do_action('trashed_comment', $comment_id);

Source code

function wp_trash_comment($comment_id) {

	if ( !EMPTY_TRASH_DAYS )

		return wp_delete_comment($comment_id, true);



	if ( !$comment = get_comment($comment_id) )

		return false;



	do_action('trash_comment', $comment_id);



	if ( wp_set_comment_status($comment_id, 'trash') ) {

		add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);

		add_comment_meta($comment_id, '_wp_trash_meta_time', time() );

		do_action('trashed_comment', $comment_id);

		return true;

	}



	return false;

}

4183

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: