AnsPress_BP_Hooks::new_comment_notification( object $comment )

Description #

New comment notification.

Parameters #

  • $comment
    object (Required) Comment object.

Source #

File: addons/free/buddypress.php

	public static function new_comment_notification( $comment ) {
		if ( ! bp_is_active( 'notifications' ) ) {
			return;
		}

		global $bp;

		$comment = (object) $comment;
		$post = get_post( $comment->comment_post_ID );
		$subscribers = [ $post->post_author ];

		$notification_args = array(
			'item_id'           => $comment->comment_ID,
			'secondary_item_id' => $comment->user_id,
			'component_name'    => $bp->ap_notifier->id,
			'component_action'  => 'new_comment_' . $post->ID,
			'date_notified'     => bp_core_current_time(),
			'is_new'            => 1,
		);

		foreach ( (array) $subscribers as $s ) {
			if ( $s != $comment->user_id ) {
				$notification_args['user_id'] = $s;
				bp_notifications_add_notification( $notification_args );
			}
		}
	}

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