bp_friends_add_friendship_accepted_notification( int $friendship_id, int $initiator_user_id, int $friend_user_id )

Notify a member when another member accepts their virtual friendship request.

Description

Parameters

$friendship_id

(Required) The unique ID of the friendship.

$initiator_user_id

(Required) The friendship initiator user ID.

$friend_user_id

(Required) The friendship request receiver user ID.

Source

File: bp-friends/bp-friends-notifications.php

function bp_friends_add_friendship_accepted_notification( $friendship_id, $initiator_user_id, $friend_user_id ) {
	// Remove the friend request notice.
	bp_notifications_mark_notifications_by_item_id( $friend_user_id, $initiator_user_id, buddypress()->friends->id, 'friendship_request' );

	// Add a friend accepted notice for the initiating user.
	bp_notifications_add_notification(  array(
		'user_id'           => $initiator_user_id,
		'item_id'           => $friend_user_id,
		'secondary_item_id' => $friendship_id,
		'component_name'    => buddypress()->friends->id,
		'component_action'  => 'friendship_accepted',
		'date_notified'     => bp_core_current_time(),
		'is_new'            => 1,
	) );
}

Changelog

Changelog
Version Description
BuddyPress 1.9.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.