bbp_buddypress_add_notification( int $reply_id, int $topic_id, int $forum_id, array $anonymous_data = array(), int $author_id, bool $is_edit = false, int $reply_to )

Hooked into the new reply function, this notification action is responsible for notifying topic and hierarchical reply authors of topic replies.


Description Description


Parameters Parameters

$reply_id

(Required)

$topic_id

(Required)

$forum_id

(Required) (not used)

$anonymous_data

(Optional) (not used)

Default value: array()

$author_id

(Required)

$is_edit

(Optional) Used to bail if this gets hooked to an edit action

Default value: false

$reply_to

(Required)


Top ↑

Source Source

File: includes/extend/buddypress/notifications.php

function bbp_buddypress_add_notification( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $author_id = 0, $is_edit = false, $reply_to = 0 ) {

	// Bail if somehow this is hooked to an edit action
	if ( ! empty( $is_edit ) ) {
		return;
	}

	// Get author information
	$topic_author_id   = bbp_get_topic_author_id( $topic_id );
	$secondary_item_id = $author_id;

	// Hierarchical replies
	if ( ! empty( $reply_to ) ) {
		$reply_to_item_id = bbp_get_topic_author_id( $reply_to );
	}

	// Get some reply information
	$args = array(
		'user_id'          => $topic_author_id,
		'item_id'          => $reply_id,
		'component_name'   => bbp_get_component_name(),
		'component_action' => 'bbp_new_reply',
		'date_notified'    => get_post( $reply_id )->post_date,
	);

	// Notify the topic author if not the current reply author
	if ( $author_id !== $topic_author_id ) {
		$args['secondary_item_id'] = $secondary_item_id ;

		bp_notifications_add_notification( $args );
	}

	// Notify the immediate reply author if not the current reply author
	if ( ! empty( $reply_to ) && ( $author_id !== $reply_to_item_id ) ) {
		$args['user_id']           = $reply_to_item_id;
		$args['secondary_item_id'] = $topic_author_id;

		bp_notifications_add_notification( $args );
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.