bp_groups_get_group_type( int $group_id, bool $single = true )
Get type for a group.
Description
Parameters
- $group_id
-
(Required) ID of the group.
- $single
-
(Optional) Whether to return a single type string. If multiple types are found for the group, the oldest one will be returned. Default: true.
Default value: true
Return
(string|array|bool) On success, returns a single group type (if $single
is true) or an array of group types (if $single
is false). Returns false on failure.
Source
File: bp-groups/bp-groups-functions.php
3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 | function bp_groups_get_group_type( $group_id , $single = true ) { $types = wp_cache_get( $group_id , 'bp_groups_group_type' ); if ( false === $types ) { $raw_types = bp_get_object_terms( $group_id , 'bp_group_type' ); if ( ! is_wp_error( $raw_types ) ) { $types = array (); // Only include currently registered group types. foreach ( $raw_types as $gtype ) { if ( bp_groups_get_group_type_object( $gtype ->name ) ) { $types [] = $gtype ->name; } } wp_cache_set( $group_id , $types , 'bp_groups_group_type' ); } } $type = false; if ( ! empty ( $types ) ) { if ( $single ) { $type = end ( $types ); } else { $type = $types ; } } /** * Filters a groups's group type(s). * * @since BuddyPress 2.6.0 * * @param string|array $type Group type. * @param int $group_id ID of the group. * @param bool $single Whether to return a single type string, or an array. */ return apply_filters( 'bp_groups_get_group_type' , $type , $group_id , $single ); } |
Changelog
Version | Description |
---|---|
BuddyPress 2.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.