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 Description


Parameters 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


Top ↑

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


Top ↑

Source 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 );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.