Skip to:
Content
Pages
Categories
Search
Top
Bottom

Can't accept friendship request if both users ask for it

  • @ottolini

    Participant

    Two users asked for friendship, so in the bp_friends table we have two records:

    
    id    initiator_user_id   friend_user_id  is_confirmed
     1         26                      5             0
     2          5                     26             0
    

    Now, member 5 would like to accept friendship request from member 26, but the following code doesn’t work:

    
            $friendship_id = BP_Friends_Friendship::get_friendship_id( $current_user_id, $id );
            friends_accept_friendship( $friendship_id );
    

    The reason lies in the function get_friendship_id, because it doesn’t return 1, but 2, which is the id of the request member 5 made to 26 and not vice versa.
    Call to friends_accept_friendship with id=2 failed because the logged in user is 5 and not 26.
    I think that get_friendship_id should only return the id of the matching record and not the first record that contains the pair of users.

Viewing 4 replies - 1 through 4 (of 4 total)
  • @rosyteddy

    Participant

    @danbp

    Participant

    Hi @ottolini,

    can you give details about what you’re doing please ?

    In your example user 26 ask user 5 for frienship and user 5 is askink the same to user 26.

    This is a theoric situation, because by default, when 26 ask to 5, 5 can’t ask for the same to 26. On the member directory or on 26 profile, 5 will see a “frienship requested” button, which let him accept or reject 26’s request.

    So i guess this behave is intended to avoid request colision. But i could be wrong, thank you for further explanation. 😉

    @ottolini

    Participant

    I’m currently developing a json API interface to BuddyPress based on on the BP-API project. I understand that this should not happen if a member uses the “normal” web interface, but if you access Buddypress functions through an API, like a mobile app, this could happen.
    So, from my point of view, there are two solutions:

    1) change the behaviour of friends_add_friend function so that if somebody ask for a friendship with someone that did the same in the past, just make the friendship happen because this is the implied action the member wanted to achieve
    2) modify the behaviour of get_friendship_id as suggested earlier

    Of course I’m open to any other suggestion…

    @danbp

    Participant

    Suggest you open an enhancement ticket to get some dev advice about this. Give an explicit title, a short description of the situation and simply link to this topic.

    https://buddypress.trac.wordpress.org/report
    Your Login credentials are the same as on this forum.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can't accept friendship request if both users ask for it’ is closed to new replies.
Skip to toolbar