Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Buddypress how to make two user friends by their user id via custom code

@boonebgorges

Keymaster

Hi @ankitjoshi11 – Check out the file buddypress/bp-friends/bp-friends-functions.php. The functions you’ll need are:


friends_add_friend( $initiator_userid, $friend_userid );

which accepts a third $force_accept parameter which makes it unnecessary for user B to manually accept. If you want to handle acceptance separately, look at


friends_accept_friendship( $friendship_id );

You can get the $friendship_id for two users with friends_get_friendship_id( $user_a, $user_b );

Good luck with your project!

Skip to toolbar