bp_get_group_type( object|bool $group = false )
Get the type of the current group in the loop.
Description
Parameters
- $group
-
(Optional) Group object. Default: current group in loop.
Default value: false
Return
(string)
Source
File: bp-groups/bp-groups-template.php
function bp_get_group_type( $group = false ) {
global $groups_template;
if ( empty( $group ) ) {
$group =& $groups_template->group;
}
if ( true === bp_disable_group_type_creation() ) {
$group_type = bp_groups_get_group_type( $group->id );
$group_type = bp_groups_get_group_type_object( $group_type );
$group_type = isset( $group_type->labels['singular_name'] ) ? $group_type->labels['singular_name'] : '';
if ( 'public' == $group->status ) {
$group_visibility = __( 'Public', 'buddyboss' );
$type = !empty( $group_type ) ? '<span class="group-visibility public">'.$group_visibility.'</span> <span class="type-separator">/</span> <span class="group-type">'.$group_type.'</span>' : '<span class="group-visibility public">'.__( "Public", 'buddyboss' ).' <span class="type-separator">/</span> <span class="group-type">'.__( "Group", 'buddyboss' ).'</span>';
} elseif ( 'hidden' == $group->status ) {
$group_visibility = __( 'Hidden', 'buddyboss' );
$type = !empty( $group_type ) ? '<span class="group-visibility hidden">'.$group_visibility.'</span> <span class="type-separator">/</span> <span class="group-type">'.$group_type.'</span>' : '<span class="group-visibility hidden">'.__( "Hidden", 'buddyboss' ).' <span class="type-separator">/</span> <span class="group-type">'.__( "Group", 'buddyboss' ).'</span>';
} elseif ( 'private' == $group->status ) {
$group_visibility = __( 'Private', 'buddyboss' );
$type = !empty( $group_type ) ? '<span class="group-visibility private">'.$group_visibility.'</span> <span class="type-separator">/</span> <span class="group-type">'.$group_type.'</span>' : '<span class="group-visibility private">'.__( "Private", 'buddyboss' ).' <span class="type-separator">/</span> <span class="group-type">'.__( "Group", 'buddyboss' ).'</span>';
} else {
$type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddyboss' );
}
} else {
if ( 'public' == $group->status ) {
$type = '<span class="group-visibility public">' . __( "Public Group", 'buddyboss' ) . '</span>';
} elseif ( 'hidden' == $group->status ) {
$type = '<span class="group-visibility hidden">' . __( "Hidden Group", 'buddyboss' ) . '</span>';
} elseif ( 'private' == $group->status ) {
$type ='<span class="group-visibility private">' . __( "Private Group", 'buddyboss' ) . '</span>';
} else {
$type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddyboss' );
}
}
/**
* Filters the type for the current group in the loop.
*
* @since BuddyPress 1.0.0
* @since BuddyPress 2.5.0 Added the `$group` parameter.
*
* @param string $type Type for the current group in the loop.
* @param object $group Group object.
*/
return apply_filters( 'bp_get_group_type', $type, $group );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.0.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.