Yes, I tried to change the type of member and then put back the correct one but it doesn’t work
if you want I can also provide you with FTP access
Hi Emanuele,
Thank you.Please do. That will help us check and update the code as needed.
Thank you
BrajeshHi Emanuele,
Thank you for the patience.There was a minor update needed in the code.
Here it is
/** * Add as friend other user with same member type on user member change. */ add_action( 'bp_set_member_type', function ( $user_id, $member_type ) { $member_type = (array) $member_type; if ( ! in_array( 'partner', $member_type ) ) { return; } $users = new BP_User_Query( array( 'member_type' => 'partner', 'populate_extras' => false, ) ); if ( ! $users->total_users ) { return; } foreach ( $users->user_ids as $id ) { if ( $id == $user_id ) { continue; } if ( ! friends_check_friendship( $user_id, $id ) ) { friends_add_friend( $id, $user_id, true ); } } }, 10, 2 );
It is working on the staging site now. I have put ti in the child theme’s functions.php
Regards
BrajeshPS:- I tested by changing a user’s member type, Please revert them.
Hi Brajesh,
I try to change a member and they became friends correctly.
But now, if I rechange the member types, the friendship remains … I don’t want that to happen.I would like only the “partners” to remain friends.
thanks for supportHi Emanuele,
Thank you for confirming.I am sorry, there is no way to know in BuddyPress when a specific member type was removed. If you remove a member types, it uses set member type action. So,m we don’t have access to previous member type to determine if we should remove all friends.
If you want, we can add the code for a condition like this. If a user’s member type is set to None(”), we remove all friends. It will apply for all member type though.
Regards
BrajeshAh, I understand.
For now, thanks Brajesh.
We will try to pay attention to the assignment of usersThanks for the support.
Hi Emanuele ,
Thank you for the understanding.Regards
Brajesh
The topic ‘ [Resolved] Problem to Setting Auto Friendship’ is closed to new replies.