friends_withdraw_friendship

Withdraw a friendship request.

Description

friends_withdraw_friendship( (int) $initiator_userid, (int) $friend_userid ); 

Parameters (2)

0. $initiator_userid (int)
ID of the friendship initiator - this is the user who requested the friendship, and is doing the withdrawing.
1. $friend_userid (int)
ID of the requested friend.

Usage

  1. if ( !function_exists( 'friends_withdraw_friendship' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-friends/bp-friends-functions.php'; 
  3.  
  4. // ID of the friendship initiator - this is the 
  5. // user who requested the friendship, and is doing the withdrawing. 
  6. $initiator_userid = -1; 
  7.  
  8. // ID of the requested friend. 
  9. $friend_userid = -1; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = friends_withdraw_friendship($initiator_userid, $friend_userid); 
  13.  

Defined (1)

The function is defined in the following location(s).

/bp-friends/bp-friends-functions.php  
  1. function friends_withdraw_friendship( $initiator_userid, $friend_userid ) { 
  2. $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid ); 
  3. $friendship = new BP_Friends_Friendship( $friendship_id, true, false ); 
  4.  
  5. if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::withdraw( $friendship_id ) ) { 
  6.  
  7. // @deprecated Since 1.9 
  8. do_action_ref_array( 'friends_friendship_whithdrawn', array( $friendship_id, &$friendship ) ); 
  9.  
  10. /** 
  11. * Fires after a friendship request has been withdrawn. 
  12. * @since 1.9.0 
  13. * @param int $friendship_id ID of the friendship. 
  14. * @param BP_Friends_Friendship $friendship Friendship object. Passed by reference. 
  15. */ 
  16. do_action_ref_array( 'friends_friendship_withdrawn', array( $friendship_id, &$friendship ) ); 
  17.  
  18. return true; 
  19.  
  20. return false;