bp_nouveau_ajax_remove_group_invite()
AJAX remove group invite.
Description
Source
File: bp-templates/bp-nouveau/includes/groups/ajax.php
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
| 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.