friends_notification_new_request( int $friendship_id, int $initiator_id, int $friend_id )
Send notifications related to a new friendship request.
Description
When a friendship is requested, an email and a BP notification are sent to the user of whom friendship has been requested ($friend_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
function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) { if ( 'no' == bp_get_user_meta( (int) $friend_id, 'notification_friends_friendship_request', true ) ) { return; } $unsubscribe_args = array( 'user_id' => $friend_id, 'notification_type' => 'friends-request', ); $args = array( 'tokens' => array( 'friend-requests.url' => esc_url( bp_core_get_user_domain( $friend_id ) . bp_get_friends_slug() . '/requests/' ), 'friend.id' => $friend_id, 'friendship.id' => $friendship_id, 'initiator.id' => $initiator_id, 'initiator.url' => esc_url( bp_core_get_user_domain( $initiator_id ) ), 'initiator.name' => bp_core_get_user_displayname( $initiator_id ), 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), ), ); bp_send_email( 'friends-request', $friend_id, $args ); }
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.