AnsPress_Comment_Hooks::preprocess_comment( array $commentdata )

Description #

Change comment_type while adding comments for question or answer.

Parameters #

  • $commentdata
    array (Required) Comment data array.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: includes/comments.php

	public static function preprocess_comment( $commentdata ) {
		if ( ! empty( $commentdata['comment_post_ID'] ) ) {
			$post_type = get_post_type( $commentdata['comment_post_ID'] );

			if ( in_array( $post_type, array( 'question', 'answer' ), true ) ) {
				$commentdata['comment_type'] = 'anspress';
			}
		}

		return $commentdata;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment