Please be advised that there's currently no out-of-the-box option to do this in BuddyBoss.
Modifications are typically considered custom work, but we are making an exception in this case. Kindly check our Support Policy here: https://www.buddyboss.com/support-policy/.
Modifications are typically considered custom work, but we are making an exception in this case. Kindly check our Support Policy here: https://www.buddyboss.com/support-policy/.
Kindly try adding the following code in your theme files:
1. Go to Appearance > Theme File Editor
2. Under “Select theme to edit”, choose (BuddyBoss Child/Whatever theme is active), then click “Select”.
3. Below Theme Files, select Theme Functions (functions.php).
4. Append the following just before the closing PHP tag “?>”:
/**
* Filter the group member IDs and return them sorted alphabetically by display name.
*
* @param array $value The array of user IDs to be filtered.
* @return array $sorted_users The array of sorted user IDs by display name.
*/
add_filter('bp_group_member_query_group_member_ids', 'bb_bp_group_has_members');
function bb_bp_group_has_members( $value ) {
// Arguments for fetching users by specified IDs and ordering by display name
$args = [
'include' => $value, // Include only the specified user IDs
'orderby' => 'display_name', // Order by display name
'order' => 'ASC', // Ascending order
];
// Fetch users based on the provided arguments
$users = get_users( $args );
// Initialize an empty array to hold sorted user IDs
$sorted_users = [];
// Loop through the users and collect their IDs
foreach ( $users as $user ) {
$sorted_users[] = $user->ID;
}
// Return the sorted user IDs
return $sorted_users;
}
NOTE: Please make a backup of your site.
/**
* Filter the group member IDs and return them sorted alphabetically by display name.
*
* @param array $value The array of user IDs to be filtered.
* @return array $sorted_users The array of sorted user IDs by display name.
*/
add_filter('bp_group_member_query_group_member_ids', 'bb_bp_group_has_members');
function bb_bp_group_has_members( $value ) {
// Arguments for fetching users by specified IDs and ordering by display name
$args = [
'include' => $value, // Include only the specified user IDs
'orderby' => 'display_name', // Order by display name
'order' => 'ASC', // Ascending order
];
// Fetch users based on the provided arguments
$users = get_users( $args );
// Initialize an empty array to hold sorted user IDs
$sorted_users = [];
// Loop through the users and collect their IDs
foreach ( $users as $user ) {
$sorted_users[] = $user->ID;
}
// Return the sorted user IDs
return $sorted_users;
}
NOTE: Please make a backup of your site.
5. Click “Update File”.
Did you find it helpful? Yes No
Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.