friends_remove_friend( int $initiator_userid, int $friend_userid )
Remove a friendship.
Description
Will also delete the related "friendship_accepted" activity item.
Parameters
- $initiator_userid
-
(Required) ID of the friendship initiator.
- $friend_userid
-
(Required) ID of the friend user.
Return
(bool) True on success, false on failure.
Source
File: bp-friends/bp-friends-functions.php
function friends_remove_friend( $initiator_userid, $friend_userid ) { $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid ); $friendship = new BP_Friends_Friendship( $friendship_id ); /** * Fires before the deletion of a friendship activity item * for the user who canceled the friendship. * * @since BuddyPress 1.5.0 * * @param int $friendship_id ID of the friendship object, if any, between a pair of users. * @param int $initiator_userid ID of the friendship initiator. * @param int $friend_userid ID of the friend user. */ do_action( 'friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid ); /** * Fires before the friendship connection is removed. * * This hook is misleadingly named - the friendship is not yet deleted. * This is your last chance to do something while the friendship exists. * * @since BuddyPress 1.0.0 * * @param int $friendship_id ID of the friendship object, if any, between a pair of users. * @param int $initiator_userid ID of the friendship initiator. * @param int $friend_userid ID of the friend user. */ do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid ); if ( $friendship->delete() ) { friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' ); /** * Fires after the friendship connection is removed. * * @since BuddyPress 1.8.0 * * @param int $initiator_userid ID of the friendship initiator. * @param int $friend_userid ID of the friend user. */ do_action( 'friends_friendship_post_delete', $initiator_userid, $friend_userid ); return true; } return false; }
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.