BP_Groups_Group::group_exists( string $slug, string|bool $table_name = false )

Get whether a group exists for a given slug.


Description Description


Parameters Parameters

$slug

(Required) Slug to check.

$table_name

(Optional) Deprecated.

Default value: false


Top ↑

Return Return

(int|null) Group ID if found; null if not.


Top ↑

Source Source

File: bp-groups/classes/class-bp-groups-group.php

	public static function group_exists( $slug, $table_name = false ) {
		global $wpdb;

		if ( empty( $slug ) ) {
			return false;
		}

		$args = array(
			'slug'               => $slug,
			'per_page'           => 1,
			'page'               => 1,
			'update_meta_cache'  => false,
			'show_hidden'        => true,
		);

		$groups = BP_Groups_Group::get( $args );

		$group_id = null;
		if ( $groups['groups'] ) {
			$group_id = current( $groups['groups'] )->id;
		}

		return $group_id;
	}

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.