groups_notification_membership_request_completed( int $requesting_user_id, int $group_id, bool $accepted = true )
Notify member about their group membership request.
Description
Parameters
- $requesting_user_id
-
(Required) ID of the user requesting group membership.
- $group_id
-
(Required) ID of the group.
- $accepted
-
(Optional) Whether the membership request was accepted. Default: true.
Default value: true
Source
File: bp-groups/bp-groups-notifications.php
function groups_notification_membership_request_completed( $requesting_user_id = 0, $group_id = 0, $accepted = true ) { // Trigger a BuddyPress Notification. if ( bp_is_active( 'notifications' ) ) { // What type of acknowledgement. $type = ! empty( $accepted ) ? 'membership_request_accepted' : 'membership_request_rejected'; bp_notifications_add_notification( array( 'user_id' => $requesting_user_id, 'item_id' => $group_id, 'component_name' => buddypress()->groups->id, 'component_action' => $type, ) ); } // Bail if member opted out of receiving this email. if ( 'no' === bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) ) { return; } $group = groups_get_group( $group_id ); $args = array( 'tokens' => array( 'group' => $group, 'group.id' => $group_id, 'group.name' => $group->name, 'group.url' => esc_url( bp_get_group_permalink( $group ) ), 'requesting-user.id' => $requesting_user_id, ), ); if ( ! empty( $accepted ) ) { $unsubscribe_args = array( 'user_id' => $requesting_user_id, 'notification_type' => 'groups-membership-request-accepted', ); $args['tokens']['unsubscribe'] = esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); bp_send_email( 'groups-membership-request-accepted', (int) $requesting_user_id, $args ); } else { $unsubscribe_args = array( 'user_id' => $requesting_user_id, 'notification_type' => 'groups-membership-request-rejected', ); $args['tokens']['unsubscribe'] = esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); bp_send_email( 'groups-membership-request-rejected', (int) $requesting_user_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.