Iâm still getting my head around buddypress, so far so good but Iâve hit a snag where I want certain users who are flagged as an âexpertâ to automatically accept any friend requests people make.
Iâve found a couple of functions related to this but I think Iâm missing something that would make this simpler such as setting a constant or overriding part of the $bp globalâ¦
What I have so far is the following:
function bp_auto_accept_friend_request( $friendship_id, $friendship_initiator_id, $friendship_friend_id ) {
if ( is_user_expert( $friendship_friend_id ) ) {
// force add
friends_accept_friendship( $friendship_id );
friends_add_friend( $friendship_initiator_id, $friendship_friend_id, true );
}
}
add_action('friends_friendship_requested', 'bp_auto_accept_friend_request', 200, 3);
Can anyone tell me where I should be looking to make this nice and seamless just as if the main settings were set to bypass the request process please?
UPDATE
try this
this way we only call friends_add_friend function with $force = true if they are not friends yet.