BP_Groups_Group::get_id_by_previous_slug( string $slug )
Get whether a group exists for an old slug.
Description
Parameters
- $slug
-
(Required) Slug to check.
Return
(int|null|false) Group ID if found; null if not; false if missing parameters.
Source
File: bp-groups/classes/class-bp-groups-group.php
public static function get_id_by_previous_slug( $slug ) {
global $wpdb;
if ( empty( $slug ) ) {
return false;
}
$args = array(
'meta_query' => array(
array(
'key' => 'previous_slug',
'value' => $slug
),
),
'orderby' => 'meta_id',
'order' => 'DESC',
'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 2.9.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.