BP_Groups_Group::get_by_letter( string $letter, int|null $limit = null, int|null $page = null, bool $populate_extras = true, string|array|bool $exclude = false )
Get a list of groups whose names start with a given letter.
Description
Parameters
- $letter
-
(Required) The letter.
- $limit
-
(Optional) The max number of results to return. Default: null (no limit).
Default value: null
- $page
-
(Optional) The page offset of results to return. Default: null (no limit).
Default value: null
- $populate_extras
-
(Optional) Deprecated.
Default value: true
- $exclude
-
(Optional) Array or comma-separated list of group IDs to exclude from results.
Default value: false
Return
(false|array)
- 'groups'
(array) Array of group objects returned by the paginated query. - 'total'
(int) Total count of all groups matching non- paginated query params.
Source
File: bp-groups/classes/class-bp-groups-group.php
1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 | public static function get_by_letter( $letter , $limit = null, $page = null, $populate_extras = true, $exclude = false ) { global $wpdb ; $pag_sql = $hidden_sql = $exclude_sql = '' ; // Multibyte compliance. if ( function_exists( 'mb_strlen' ) ) { if ( mb_strlen( $letter , 'UTF-8' ) > 1 || is_numeric ( $letter ) || ! $letter ) { return false; } } else { if ( strlen ( $letter ) > 1 || is_numeric ( $letter ) || ! $letter ) { return false; } } $args = array ( 'per_page' => $limit , 'page' => $page , 'search_terms' => $letter . '*' , 'search_columns' => array ( 'name' ), 'exclude' => $exclude , ); return BP_Groups_Group::get( $args ); } |
Changelog
Version | Description |
---|---|
BuddyPress 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.