Display Group(s) Column in the Manage Sites table

By using the following code snippet, you can display groups assigned to a child site in the Manage Sites table as a custom column.

add_filter( 'mainwp_sitestable_getcolumns', 'mycustom_mainwp_sitestable_getcolumns', 10, 1 );
function mycustom_mainwp_sitestable_getcolumns( $columns ) {
	$columns['groups'] = "Groups";
	return $columns;
}
add_filter( 'mainwp_sitestable_item', 'mycustom_mainwp_sitestable_item', 10, 1 );
function mycustom_mainwp_sitestable_item( $item ) {
	$website = \MainWP\Dashboard\MainWP_DB::instance()->get_website_by_id( $item['id'], true );
	if ( '' == $website->wpgroups ) {
		$item['groups'] = '';
	} else {
		$item['groups'] = $website->wpgroups;
	}
	return $item;
}
3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.