bp_nouveau_ajax_remove_group_invite()

AJAX remove group invite.

Description

Source

File: bp-templates/bp-nouveau/includes/groups/ajax.php

790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
function bp_nouveau_ajax_remove_group_invite() {
    $user_id  = (int) $_POST['user'];
    $group_id = bp_get_current_group_id();
 
    // Verify nonce
    if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'groups_invite_uninvite_user' ) ) {
        wp_send_json_error(
            array(
                'feedback' => __( 'Group invitation could not be removed.', 'buddyboss' ),
                'type'     => 'error',
            )
        );
    }
 
    if ( BP_Groups_Member::check_for_membership_request( $user_id, $group_id ) ) {
        wp_send_json_error(
            array(
                'feedback' => __( 'The member is already a member of the group.', 'buddyboss' ),
                'type'     => 'warning',
                'code'     => 1,
            )
        );
    }
 
    // Remove the unsent invitation.
    if ( ! groups_uninvite_user( $user_id, $group_id ) ) {
        wp_send_json_error(
            array(
                'feedback' => __( 'Group invitation could not be removed.', 'buddyboss' ),
                'type'     => 'error',
                'code'     => 0,
            )
        );
    }
 
    wp_send_json_success(
        array(
            'feedback'    => __( 'There are no more pending invitations for the group.', 'buddyboss' ),
            'type'        => 'info',
            'has_invites' => bp_group_has_invites( array( 'user_id' => 'any' ) ),
        )
    );
}

Changelog

Changelog
Version Description
BuddyPress 3.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.