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
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 | 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.