Ejemplo n.º 1
0
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);
    do_action('friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid);
    // Remove the activity stream item for the user who canceled the friendship
    friends_delete_activity(array('item_id' => $friendship_id, 'type' => 'friendship_accepted', 'user_id' => bp_displayed_user_id()));
    do_action('friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid);
    if ($friendship->delete()) {
        friends_update_friend_totals($initiator_userid, $friend_userid, 'remove');
        return true;
    }
    return false;
}
Ejemplo n.º 2
0
/**
 * Remove a friendship.
 *
 * Will also delete the related "friendship_accepted" activity item.
 *
 * @param int $initiator_userid ID of the friendship initiator.
 * @param int $friend_userid ID of the friend user.
 * @return bool True on success, false on failure.
 */
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);
    do_action('friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid);
    // Remove the activity stream item for the user who canceled the friendship
    friends_delete_activity(array('item_id' => $friendship_id, 'type' => 'friendship_accepted', 'user_id' => bp_displayed_user_id()));
    // This hook is misleadingly named - the friendship is not yet deleted.
    // This is your last chance to do something while the friendship exists
    do_action('friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid);
    if ($friendship->delete()) {
        friends_update_friend_totals($initiator_userid, $friend_userid, 'remove');
        do_action('friends_friendship_post_delete', $initiator_userid, $friend_userid);
        return true;
    }
    return false;
}
/**
 * Remove a friendship.
 *
 * Will also delete the related "friendship_accepted" activity item.
 *
 * @since 1.0.0
 *
 * @param int $initiator_userid ID of the friendship initiator.
 * @param int $friend_userid    ID of the friend user.
 * @return bool True on success, false on failure.
 */
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 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);
    // Remove the activity stream items about the friendship id.
    friends_delete_activity(array('item_id' => $friendship_id, 'type' => 'friendship_created', 'user_id' => 0));
    /**
     * 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 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 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;
}
Ejemplo n.º 4
0
function friends_remove_friend($initiator_userid, $friend_userid)
{
    global $bp;
    /* Check the nonce */
    if (!check_admin_referer('friends_remove_friend')) {
        return false;
    }
    $friendship_id = BP_Friends_Friendship::get_friendship_id($initiator_userid, $friend_userid);
    $friendship = new BP_Friends_Friendship($friendship_id);
    // Remove the activity stream items
    friends_delete_activity(array('item_id' => $friendship_id, 'component_name' => 'friends', 'component_action' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id));
    do_action('friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid);
    if ($friendship->delete()) {
        friends_update_friend_totals($initiator_userid, $friend_userid, 'remove');
        return true;
    }
    return false;
}