friends_accept_friendship( int $friendship_id )

Mark a connection request as accepted.

Description

Also initiates a "friendship_accepted" activity item.

Parameters

$friendship_id

(Required) ID of the pending friendship object.

Return

(bool) True on success, false on failure.

Source

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

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
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 BuddyPress 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;
}

Changelog

Changelog
Version Description
BuddyPress 1.0.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.