friends_notification_accepted_request( int $friendship_id, int $initiator_id, int $friend_id )

Send notifications related to the acceptance of a connection request.

Description

When a connection request is accepted, an email and a BP notification are sent to the user who requested the friendship ($initiator_id).

Parameters

$friendship_id

(Required) ID of the friendship object.

$initiator_id

(Required) ID of the user who initiated the request.

$friend_id

(Required) ID of the request recipient.

Source

File: bp-friends/bp-friends-functions.php

908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
    if ( 'no' == bp_get_user_meta( (int) $initiator_id, 'notification_friends_friendship_accepted', true ) ) {
        return;
    }
 
    $unsubscribe_args = array(
        'user_id'           => $initiator_id,
        'notification_type' => 'friends-request-accepted',
    );
 
    $args = array(
        'tokens' => array(
            'friend.id'      => $friend_id,
            'friendship.url' => esc_url( bp_core_get_user_domain( $friend_id ) ),
            'friend.name'    => bp_core_get_user_displayname( $friend_id ),
            'friendship.id'  => $friendship_id,
            'initiator.id'   => $initiator_id,
            'unsubscribe'      => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
        ),
    );
    bp_send_email( 'friends-request-accepted', $initiator_id, $args );
}

Changelog

Changelog
Version Description
BuddyPress 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.