AnsPress_BP_Hooks::new_answer_notification( integer $post_id )

Description #

New answer notifications.

Parameters #

  • $post_id
    integer (Required) Post ID.

Source #

File: addons/free/buddypress.php

	public static function new_answer_notification( $post_id ) {
		if ( ! bp_is_active( 'notifications' ) ) {
			return;
		}

		global $bp;

		$answer = get_post( $post_id );
		$answer = get_post( $answer->post_parent );
		$subscribers = [ $answer->post_author ];

		$notification_args = array(
			'item_id'           => $answer->ID,
			'secondary_item_id' => $answer->post_author,
			'component_name'    => $bp->ap_notifier->id,
			'component_action'  => 'new_answer_'.$answer->post_parent,
			'date_notified'     => bp_core_current_time(),
			'is_new'            => 1,
		);

		foreach ( (array) $subscribers as $s ) {
			if ( $s != $answer->post_author ) {
				$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