bp_nouveau_ajax_groups_get_group_members_listing()
Retrieve the possible members list to send group message.
Description
Source
File: bp-templates/bp-nouveau/includes/groups/ajax.php
function bp_nouveau_ajax_groups_get_group_members_listing() { if ( false === bp_disable_group_messages() ) { return; } if ( empty( $_POST['action'] ) ) { wp_send_json_error(); } $response = array( 'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'There was a problem loading recipients. Please try again.', 'buddyboss' ) . '</p></div>', 'type' => 'error', ); if ( false === bp_is_active( 'messages' ) ) { wp_send_json_error( $response ); } if ( empty( wp_unslash( $_POST['nonce'] ) ) || ! wp_verify_nonce( wp_unslash( $_POST['nonce'] ), 'retrieve_group_members' ) ) { wp_send_json_error( $response ); } $per_page = apply_filters( 'bp_nouveau_ajax_groups_get_group_members_listing_per_page', 10 ); $search_per_page = apply_filters( 'bp_nouveau_ajax_groups_get_group_members_listing_search_per_page', 99999999999999 ); $page = (int) $_POST['page']; if ( isset( $_POST['term'] ) && '' !== $_POST['term'] ) { $args = array( 'per_page' => $search_per_page, 'group_id' => $_POST['group'], 'search_terms' => $_POST['term'], 'exclude' => array( bp_loggedin_user_id() ), 'exclude_admins_mods' => false, ); } else { $args = array( 'page' => $page, 'per_page' => $per_page, 'group_id' => $_POST['group'], 'exclude' => array( bp_loggedin_user_id() ), 'exclude_admins_mods' => false, ); } $group_members = groups_get_group_members( $args ); $html = ''; $paginate = ''; $result = array(); $total_page = 0; if ( empty( $group_members['members'] ) ) { wp_send_json_success( array( 'results' => 'no_member' ) ); } else { $total_page = (int) ceil( (int) $group_members['count'] / $per_page ); ob_start(); foreach ( $group_members['members'] as $member ) { $image = htmlspecialchars_decode( bp_core_fetch_avatar( array( 'item_id' => $member->ID, 'object' => 'user', 'type' => 'thumb', 'class' => '', ) ) ); $name = bp_core_get_user_displayname( $member->ID ); ?> <li class="group-message-member-li <?php echo $member->ID; ?>"> <div class="item-avatar"> <a href="<?php echo esc_url( bp_core_get_user_domain( $member->ID ) ); ?>"> <?php echo $image; ?> </a> </div> <div class="item"> <div class="list-title member-name"> <a href="<?php echo esc_url( bp_core_get_user_domain( $member->ID ) ); ?>"> <?php echo $name; ?> </a> </div> </div> <div class="action"> <button type="button" class="button invite-button group-add-remove-invite-button bp-tooltip bp-icons" data-bp-user-id="<?php echo esc_attr( $member->ID ); ?>" data-bp-user-name="<?php echo esc_attr( $name ); ?>" data-bp-tooltip-pos="left" data-bp-tooltip="<?php esc_attr_e( 'Add Recipient', 'buddyboss' ); ?>"> <span class="icons" aria-hidden="true"></span> <span class="bp-screen-reader-text"> <?php esc_html_e( 'Add Recipient', 'buddyboss' ); ?> </span> </button> </div> </li> <?php } if ( $total_page !== (int) $_POST['page'] ) { ?> <li class="load-more"> <div class="center"> <i class="bb-icon-loader animate-spin"></i> </div> </li> <?php } $html = ob_get_contents(); ob_clean(); if ( empty( $_POST['term'] ) ) { ob_start(); if ( 1 !== (int) $_POST['page'] ) { ?> <a href="javascript:void(0);" id="bp-group-messages-prev-page" class="button group-message-button bp-tooltip" data-bp-tooltip-pos="up" data-bp-tooltip="<?php esc_attr_e( 'Previous page', 'buddyboss' ); ?>"> <span class="dashicons dashicons-arrow-left" aria-hidden="true"></span> <span class="bp-screen-reader-text"><?php esc_html_e( 'Previous page', 'buddyboss' ); ?></span> </a> <?php } if ( $total_page !== (int) $_POST['page'] ) { $page = $page + 1; ?> <a href="javascript:void(0);" id="bp-group-messages-next-page" class="button group-message-button bp-tooltip" data-bp-tooltip-pos="up" data-bp-tooltip="<?php esc_attr_e( 'Next page', 'buddyboss' ); ?>"> <span class="bp-screen-reader-text"><?php esc_html_e( 'Next page', 'buddyboss' ); ?></span> <span class="dashicons dashicons-arrow-right" aria-hidden="true"></span> </a> <?php } $paginate = ob_get_contents(); ob_clean(); } $html = apply_filters( 'bp_nouveau_ajax_groups_get_group_members_listing_html', $html ); $total_page = apply_filters( 'bp_nouveau_ajax_groups_get_group_members_listing_total_page', $total_page ); $page = apply_filters( 'bp_nouveau_ajax_groups_get_group_members_listing_page', $page ); $paginate = apply_filters( 'bp_nouveau_ajax_groups_get_group_members_listing_paginate', $paginate ); $total_count = apply_filters( 'bp_nouveau_ajax_groups_get_group_members_listing_total', $group_members['count'] ); wp_send_json_success( array( 'results' => $html, 'total_page' => $total_page, 'page' => $page, 'pagination' => $paginate, 'total_count' => __( 'Members', 'buddyboss' ), ) ); } }
Changelog
Version | Description |
---|---|
BuddyBoss 1.2.9 | 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.