BuddyPress::mark_bp_notify_as_read( mixed $post_id )

Description #

Mark notification as read when corresponding question is loaded

Parameters #

  • $post_id
    mixed (Required) Post ID or Object.

Source #

File: addons/buddypress/buddypress.php

	public function mark_bp_notify_as_read( $post_id ) {

		if ( ! bp_is_active( 'notifications' ) || ! is_question() ) {
			return;
		}

		$user_id = get_current_user_id();

		if ( 'answer' === $post_id->post_type ) {
			bp_notifications_mark_notifications_by_item_id( $user_id, $post_id->ID, 'anspress', 'new_answer' );
		}

		if ( $post_id->comment_count >= 1 ) {
			$comments = get_comments( [ 'post_id' => $post_id->ID ] );

			foreach ( (array) $comments as $comment ) {
				bp_notifications_mark_notifications_by_item_id( $user_id, $comment->comment_ID, 'anspress', 'new_comment' );
			}
		}
	}

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Add your comment