Notifications::new_answer( integer $post_id, object $_post )

Description #

Add notification for new answer.

Parameters #

  • $post_id
    integer (Required) Post ID.
  • $_post
    object (Required) Post object.

Source #

File: addons/notifications/notifications.php

	public function new_answer( $post_id, $_post ) {
		$_question = get_post( $_post->post_parent );

		// Return if question is not available.
		if ( ! $_question ) {
			return;
		}

		// Insert the notification.
		ap_insert_notification(
			array(
				'user_id'  => $_question->post_author,
				'actor'    => $_post->post_author,
				'parent'   => $_post->post_parent,
				'ref_id'   => $_post->ID,
				'ref_type' => 'answer',
				'verb'     => 'new_answer',
			)
		);
	}

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