friends_remove_data( int $user_id )

Remove all friends-related data concerning a given user.

Description

Removes the following:

  • Connections of which the user is a member.
  • Cached friend count for the user.
  • Notifications of connection requests sent by the user.

Parameters

$user_id

(Required) ID of the user whose friend data is being removed.

Source

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

756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
function friends_remove_data( $user_id ) {
 
    /**
     * Fires before deletion of friend-related data for a given user.
     *
     * @since BuddyPress 1.5.0
     *
     * @param int $user_id ID for the user whose friend data is being removed.
     */
    do_action( 'friends_before_remove_data', $user_id );
 
    BP_Friends_Friendship::delete_all_for_user( $user_id );
 
    // Remove usermeta.
    bp_delete_user_meta( $user_id, 'total_friend_count' );
 
    /**
     * Fires after deletion of friend-related data for a given user.
     *
     * @since BuddyPress 1.0.0
     *
     * @param int $user_id ID for the user whose friend data is being removed.
     */
    do_action( 'friends_remove_data', $user_id );
}

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.