Site Count Column in the Network Users List
Adds a column to Network Admin > Users showing how many sites each person belongs to, with the site names in a tooltip.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
add_filter( 'wpmu_users_columns', function ( $columns ) {
$columns['wpide_site_count'] = __( 'Site count' );
return $columns;
} );
add_filter( 'manage_users_custom_column', function ( $output, $column, $user_id ) {
if ( 'wpide_site_count' !== $column ) {
return $output;
}
$blogs = get_blogs_of_user( $user_id );
$names = wp_list_pluck( $blogs, 'blogname' );
return sprintf( '<span title="%1$s">%2$d</span>', esc_attr( implode( ', ', $names ) ), count( $blogs ) );
}, 10, 3 );
Notes
""
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.