Skip to:
Content
Pages
Categories
Search
Top
Bottom
Codex HomeBuddyPress Plugin Development → Groups Admin – Add Custom Column

Groups Admin – Add Custom Column

It can be very handy to see additional information about each group when viewing the Groups screen in wp-admin.

The necessary hooks are found in this file: buddypress/bp-groups/classes/class-bp-groups-list-table.php

This example will add a column to show the number of pending member requests to join each private group. If a group is public there can be no pending requests, so we’ll show a simple dash in that row.

// add the column
function groups_admin_add_custom_column( $columns ) {
	
    $columns["pending_group_members"] = "Join Requests";
	
    return $columns;

}
add_filter( "bp_groups_list_table_get_columns", "groups_admin_add_custom_column" );


// add the column data for each row
function groups_admin_custom_column_content( $retval = "", $column_name, $item ) {
	
	if ( "pending_group_members" !== $column_name ) {
		return $retval;
	}
	
	
	if ( "private" == $item["status"] ) {
		
		$user_ids = BP_Groups_Member::get_all_membership_request_user_ids( $item["id"] );
		
		return count( $user_ids );		
	}
	
	return "-";
	
}
add_filter( "bp_groups_admin_get_group_custom_column", "groups_admin_custom_column_content", 10, 3 );

This code can be placed in bp-custom.php .

Skip to toolbar