groups_action_clean_up_invites_requests( $user_id,  $group_id )

Clean up requests/invites when a member leaves a group.

Description

Source

File: bp-groups/actions/leave-group.php

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function groups_action_clean_up_invites_requests( $user_id, $group_id ) {
 
    $invites_class = new BP_Groups_Invitation_Manager();
    // Remove invitations/requests where the deleted user is the receiver.
    $invites_class->delete( array(
        'user_id' => $user_id,
        'item_id' => $group_id,
        'type'    => 'all'
    ) );
    /**
     * Remove invitations where the deleted user is the sender.
     * We'll use groups_uninvite_user() so that notifications will be cleaned up.
     */
    $pending_invites = groups_get_invites( array(
        'inviter_id' => $user_id,
        'item_id'    => $group_id,
    ) );
 
    if ( $pending_invites ) {
        foreach ( $pending_invites as $invite ) {
            groups_uninvite_user( $invite->user_id, $group_id, $user_id );
        }
    }
}

Changelog

Changelog
Version Description
BuddyPress 5.0.0 BuddyPress 5.0.0
BuddyBoss 1.3.5 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.