Skip to:
Content

BuddyPress.org

Ticket #7833: 7833.patch

File 7833.patch, 1.2 KB (added by imath, 8 years ago)
  • src/bp-templates/bp-nouveau/includes/friends/ajax.php

    diff --git src/bp-templates/bp-nouveau/includes/friends/ajax.php src/bp-templates/bp-nouveau/includes/friends/ajax.php
    index 7fb0087bb..25b970131 100644
    function bp_nouveau_ajax_addremove_friend() { 
    9696        // Cast fid as an integer.
    9797        $friend_id = (int) $_POST['item_id'];
    9898
    99         $user = get_user_by( 'id', $friend_id );
    100         if ( ! $user ) {
    101                 wp_send_json_error(
    102                         array(
    103                                 'feedback' => sprintf(
    104                                         '<div class="bp-feedback error">%s</div>',
    105                                         esc_html__( 'No member found by that ID.', 'buddypress' )
    106                                 ),
    107                         )
    108                 );
     99        // Check if the user exists only when the Friend ID is not a Frienship ID.
     100        if ( isset( $_POST['action'] ) && $_POST['action'] !== 'friends_accept_friendship' && $_POST['action'] !== 'friends_reject_friendship' ) {
     101                $user = get_user_by( 'id', $friend_id );
     102                if ( ! $user ) {
     103                        wp_send_json_error(
     104                                array(
     105                                        'feedback' => sprintf(
     106                                                '<div class="bp-feedback error">%s</div>',
     107                                                esc_html__( 'No member found by that ID.', 'buddypress' )
     108                                        ),
     109                                )
     110                        );
     111                }
    109112        }
    110113
    111114        // In the 2 first cases the $friend_id is a friendship id.