bp_nouveau_ajax_get_users_to_invite()
Source Source
File: bp-templates/bp-nouveau/includes/groups/ajax.php
function bp_nouveau_ajax_get_users_to_invite() { $bp = buddypress(); $response = array( 'feedback' => __( 'There was a problem performing this action. Please try again.', 'buddypress' ), 'type' => 'error', ); if ( empty( $_POST['nonce'] ) ) { wp_send_json_error( $response ); } // Use default nonce $nonce = $_POST['nonce']; $check = 'bp_nouveau_groups'; // Use a specific one for actions needed it if ( ! empty( $_POST['_wpnonce'] ) && ! empty( $_POST['action'] ) ) { $nonce = $_POST['_wpnonce']; $check = $_POST['action']; } // Nonce check! if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, $check ) ) { wp_send_json_error( $response ); } $request = bp_parse_args( $_POST, array( 'scope' => 'members', ), 'nouveau_ajax_get_users_to_invite' ); $bp->groups->invites_scope = 'members'; $message = __( 'Select members to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" navigation item to continue.', 'buddypress' ); if ( 'friends' === $request['scope'] ) { $request['user_id'] = bp_loggedin_user_id(); $bp->groups->invites_scope = 'friends'; $message = __( 'Select friends to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" navigation item to continue.', 'buddypress' ); } if ( 'invited' === $request['scope'] ) { if ( ! bp_group_has_invites( array( 'user_id' => 'any' ) ) ) { wp_send_json_error( array( 'feedback' => __( 'No pending group invitations found.', 'buddypress' ), 'type' => 'info', ) ); } $request['is_confirmed'] = false; $bp->groups->invites_scope = 'invited'; $message = __( 'You can view the group\'s pending invitations from this screen.', 'buddypress' ); } $potential_invites = bp_nouveau_get_group_potential_invites( $request ); if ( empty( $potential_invites->users ) ) { $error = array( 'feedback' => __( 'No members were found. Try another filter.', 'buddypress' ), 'type' => 'info', ); if ( 'friends' === $bp->groups->invites_scope ) { $error = array( 'feedback' => __( 'All your friends are already members of this group, or have already received an invite to join this group, or have requested to join it.', 'buddypress' ), 'type' => 'info', ); if ( 0 === (int) bp_get_total_friend_count( bp_loggedin_user_id() ) ) { $error = array( 'feedback' => __( 'You have no friends!', 'buddypress' ), 'type' => 'info', ); } } unset( $bp->groups->invites_scope ); wp_send_json_error( $error ); } $potential_invites->users = array_map( 'bp_nouveau_prepare_group_potential_invites_for_js', array_values( $potential_invites->users ) ); $potential_invites->users = array_filter( $potential_invites->users ); // Set a message to explain use of the current scope $potential_invites->feedback = $message; unset( $bp->groups->invites_scope ); wp_send_json_success( $potential_invites ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |