targetdir
El Presidente
Just Getting Started
Member Likes (0)
Hello,
On Buddypress, I would like friendship requests to automatically accept so the user does not have to accept the request.
function bp_auto_accept_friend_request( $friendship_id, $friendship_initiator_id, $friendship_friend_id ) {
$friendship_status = BP_Friends_Friendship::check_is_friend( $friendship_initiator_id, $friendship_friend_id );
if ( 'pending' == $friendship_status ) {
// force add
friends_add_friend( $friendship_initiator_id, $friendship_friend_id, $force_accept = true );
friends_accept_friendship( $friendship_id );
// Update friend totals
friends_update_friend_totals( $friendship_initiator_id, $friendship_friend_id, 'add' );
}
}
add_action('friends_friendship_requested', 'bp_auto_accept_friend_request', 200, 3);
This works as required. However, the BP buttons still say, "Friendship Requested" even though they are already friends. Any ideas?
Responses (1)
People Person (joined February 2012) Likes (0)
Not sure if this will help but here a snippet some some custom code for removing the friend notice when accepted, it was used for a different purpose, but maybe it provides some direction:
WordPress Questions?
We've got answers!
Find out more »