BP_Groups_Group::group_exists( string $slug, string|bool $table_name = false )
Get whether a group exists for a given slug.
Description
Parameters
- $slug
-
(Required) Slug to check.
- $table_name
-
(Optional) Deprecated.
Default value: false
Return
(int|null) Group ID if found; null if not.
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; }
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.