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

723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
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
770
771
772
773
774
775
776
777
778
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

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.