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
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.