bp_groups_admin_index()

Display the Groups admin index screen.

Description

This screen contains a list of all BuddyBoss groups.

Source

File: bp-groups/bp-groups-admin.php

1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
function bp_groups_admin_index() {
    global $bp_groups_list_table, $plugin_page;
 
    $messages = array();
 
    // If the user has just made a change to a group, build status messages.
    if ( ! empty( $_REQUEST['deleted'] ) ) {
        $deleted  = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
 
        if ( $deleted > 0 ) {
            $messages[] = sprintf( _n( '%s group has been permanently deleted.', '%s groups have been permanently deleted.', $deleted, 'buddyboss' ), number_format_i18n( $deleted ) );
        }
    }
 
    // Prepare the group items for display.
    $bp_groups_list_table->prepare_items();
 
    /**
     * Fires before the display of messages for the edit form.
     *
     * Useful for plugins to modify the messages before display.
     *
     * @since BuddyPress 1.7.0
     *
     * @param array $messages Array of messages to be displayed.
     */
    do_action( 'bp_groups_admin_index', $messages ); ?>
 
    <div class="wrap">
        <?php if ( version_compare( $GLOBALS['wp_version'], '4.8', '>=' ) ) : ?>
 
            <h1 class="wp-heading-inline"><?php _e( 'Groups', 'buddyboss' ); ?></h1>
 
            <?php if ( is_user_logged_in() && bp_user_can_create_groups() ) : ?>
                <a class="page-title-action" href="<?php echo esc_url( add_query_arg([ 'page' => 'bp-groups', 'create' => 'create-from-admin', 'action' => 'edit', ], admin_url( 'admin.php' ) ) ); ?>"><?php _e( 'New Group', 'buddyboss' ); ?></a>
            <?php endif; ?>
 
            <?php if ( !empty( $_REQUEST['s'] ) ) : ?>
                <span class="subtitle"><?php printf( __( 'Search results for "%s"', 'buddyboss' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ); ?></span>
            <?php endif; ?>
 
            <hr class="wp-header-end">
 
        <?php else : ?>
 
        <h1>
            <?php _e( 'Groups', 'buddyboss' ); ?>
 
            <?php if ( is_user_logged_in() && bp_user_can_create_groups() ) : ?>
                <a class="add-new-h2" href="<?php echo esc_url( add_query_arg([ 'page' => 'bp-groups', 'create' => 'create-from-admin', 'action' => 'edit', ], admin_url( 'admin.php' ) ) ); ?>"><?php _e( 'New Group', 'buddyboss' ); ?></a>
            <?php endif; ?>
 
            <?php if ( !empty( $_REQUEST['s'] ) ) : ?>
                <span class="subtitle"><?php printf( __( 'Search results for "%s"', 'buddyboss' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ); ?></span>
            <?php endif; ?>
        </h1>
 
        <?php endif; ?>
 
        <?php // If the user has just made a change to an group, display the status messages. ?>
        <?php if ( !empty( $messages ) ) : ?>
            <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>
        <?php endif; ?>
 
        <?php // Display each group on its own row. ?>
        <?php $bp_groups_list_table->views(); ?>
 
        <form id="bp-groups-form" action="" method="get">
            <?php $bp_groups_list_table->search_box( __( 'Search all Groups', 'buddyboss' ), 'bp-groups' ); ?>
            <input type="hidden" name="page" value="<?php echo esc_attr( $plugin_page ); ?>" />
            <?php $bp_groups_list_table->display(); ?>
        </form>
 
    </div>
 
<?php
}

Changelog

Changelog
Version Description
BuddyPress 1.7.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.