bp_nouveau_ajax_remove_group_invite()
Source 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(); $response = array( 'feedback' => __( 'Group invitation could not be removed.', 'buddypress' ), 'type' => 'error', ); // Verify nonce if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'groups_invite_uninvite_user' ) ) { wp_send_json_error( $response ); } // Verify that a sent invite exists. $inviter_ids = groups_get_invites( array( 'user_id' => $user_id, 'item_id' => $group_id, 'invite_sent' => 'sent', 'fields' => 'inviter_ids' ) ); if ( empty( $inviter_ids ) ) { wp_send_json_error( $response ); } // Is the current user the inviter? $inviter_id = in_array( bp_loggedin_user_id(), $inviter_ids, true ) ? bp_loggedin_user_id() : false; // A site moderator, group admin or the inviting user should be able to remove an invitation. if ( ! bp_is_item_admin() && ! $inviter_id ) { wp_send_json_error( $response ); } if ( groups_is_user_member( $user_id, $group_id ) ) { wp_send_json_error( array( 'feedback' => __( 'The member is already a member of the group.', 'buddypress' ), 'type' => 'warning', 'code' => 1, ) ); } // Remove the invitation. if ( ! groups_uninvite_user( $user_id, $group_id, $inviter_id ) ) { wp_send_json_error( array( 'feedback' => __( 'Group invitation could not be removed.', 'buddypress' ), 'type' => 'error', 'code' => 0, ) ); } wp_send_json_success( array( 'feedback' => __( 'There are no more pending invitations for the group.', 'buddypress' ), 'type' => 'info', 'has_invites' => bp_group_has_invites( array( 'user_id' => 'any' ) ), ) ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |