friends_accept_friendship( int $friendship_id )

Mark a friendship request as accepted.


Description Description

Also initiates a "friendship_accepted" activity item.


Parameters Parameters

$friendship_id

(Required) ID of the pending friendship object.


Top ↑

Return Return

(bool) True on success, false on failure.


Top ↑

Source Source

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

function friends_accept_friendship( $friendship_id ) {

	// Get the friendship data.
	$friendship = new BP_Friends_Friendship( $friendship_id, true, false );

	// Accepting friendship.
	if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::accept( $friendship_id ) ) {

		// Bump the friendship counts.
		friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );

		/**
		 * Fires after a friendship is accepted.
		 *
		 * @since 1.0.0
		 *
		 * @param int    $id                ID of the pending friendship object.
		 * @param int    $initiator_user_id ID of the friendship initiator.
		 * @param int    $friend_user_id    ID of the user requested friendship with.
		 * @param object $friendship        BuddyPress Friendship Object.
		 */
		do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship );

		return true;
	}

	return false;
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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