This method has been deprecated.
BP_Groups_Member::get_all_for_group( int $group_id, bool|int $limit = false, bool|int $page = false, bool $exclude_admins_mods = true, bool $exclude_banned = true, bool|array $exclude = false )
Get members of a group.
Description
Parameters
- $group_id
-
(Required) ID of the group being queried for.
- $limit
-
(Optional) Max amount to return.
Default value: false
- $page
-
(Optional) Pagination value.
Default value: false
- $exclude_admins_mods
-
(Optional) Whether or not to exclude admins and moderators.
Default value: true
- $exclude_banned
-
(Optional) Whether or not to exclude banned members.
Default value: true
- $exclude
-
(Optional) Array of user IDs to exclude.
Default value: false
Return
(false|array)
Source
File: bp-groups/classes/class-bp-groups-member.php
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 | public static function get_all_for_group( $group_id , $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false ) { global $wpdb ; _deprecated_function( __METHOD__ , '1.8' , 'BP_Group_Member_Query' ); $pag_sql = '' ; if ( ! empty ( $limit ) && ! empty ( $page ) ) $pag_sql = $wpdb ->prepare( "LIMIT %d, %d" , intval ( ( $page - 1 ) * $limit ), intval ( $limit ) ); $exclude_admins_sql = '' ; if ( ! empty ( $exclude_admins_mods ) ) $exclude_admins_sql = "AND is_admin = 0 AND is_mod = 0" ; $banned_sql = '' ; if ( ! empty ( $exclude_banned ) ) $banned_sql = " AND is_banned = 0" ; $exclude_sql = '' ; if ( ! empty ( $exclude ) ) { $exclude = implode( ',' , wp_parse_id_list( $exclude ) ); $exclude_sql = " AND m.user_id NOT IN ({$exclude})" ; } $bp = buddypress(); if ( bp_is_active( 'xprofile' ) ) { /** * Filters the SQL prepared statement used to fetch group members. * * @since BuddyPress 1.5.0 * * @param string $value SQL prepared statement for fetching group members. */ $members = $wpdb ->get_results( apply_filters( 'bp_group_members_user_join_filter' , $wpdb ->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, pd.value as display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u, {$bp->profile->table_name_data} pd WHERE u.ID = m.user_id AND u.ID = pd.user_id AND pd.field_id = 1 AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}" , $group_id ) ) ); } else { /** This filter is documented in bp-groups/bp-groups-classes */ $members = $wpdb ->get_results( apply_filters( 'bp_group_members_user_join_filter' , $wpdb ->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID = m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}" , $group_id ) ) ); } if ( empty ( $members ) ) { return false; } if ( empty ( $pag_sql ) ) { $total_member_count = count ( $members ); } else { /** * Filters the SQL prepared statement used to fetch group members total count. * * @since BuddyPress 1.5.0 * * @param string $value SQL prepared statement for fetching group member count. */ $total_member_count = $wpdb ->get_var( apply_filters( 'bp_group_members_count_user_join_filter' , $wpdb ->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} m WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql}" , $group_id ) ) ); } // Fetch whether or not the user is a friend. foreach ( ( array ) $members as $user ) $user_ids [] = $user ->user_id; $user_ids = implode( ',' , wp_parse_id_list( $user_ids ) ); if ( bp_is_active( 'friends' ) ) { $friend_status = $wpdb ->get_results( $wpdb ->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )" , bp_loggedin_user_id(), bp_loggedin_user_id() ) ); for ( $i = 0, $count = count ( $members ); $i < $count ; ++ $i ) { foreach ( ( array ) $friend_status as $status ) { if ( $status ->initiator_user_id == $members [ $i ]->user_id || $status ->friend_user_id == $members [ $i ]->user_id ) { $members [ $i ]->is_friend = $status ->is_confirmed; } } } } return array ( 'members' => $members , 'count' => $total_member_count ); } |
Changelog
Version | Description |
---|---|
1.6.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.