Add user columns to network users view in WordPress Multisite

It is incredible how little information there is on regarding the users page on a WP network install. This user’s view can be used for a variety of purposes depending on your website’s structure.

For example, if you use wp multisite to be able to offer a multilanguage experience to your users, where each site is a different language, the users view inside the network admin could be your unique place to control what are your users doing inside your different sites.

In this postIi’ll explain the basics on how to add new columns to the user network admin view, so you can start playing with some of your custom code and give life to this long forgotten are of wordpress.

First of all you need to declare two functions, each using a filter specifically made for networks users’ view:

  • wpmu_users_columns
  • wpmu_users_custom_column

For example:
function my_user_report_network_add_extra_user_column($columns) {
return array_merge( $columns,
array('courses' => __('Courses','my-plugin'),
'last_login' => __('Last Login','my-plugin'),
'user_country' => __('Country','my-plugin'),
'user_notes_note' => __('Notes','my-plugin')
add_filter('wpmu_users_columns' , 'my_user_report_network_add_extra_user_column');

function my_user_report_network_add_post_type_column( $value, $column_name, $user_id ) {
if($column_name == 'user_notes_note') { }

add_action( 'wpmu_users_custom_column', 'my_user_report_network_add_post_type_column', 15, 3 );

Using these two functions and filters/actions you can display as many columns you want inside your network users view.

Play with it, remember that the ‘courses’, ‘last_login’, etc columns are added here as examples, so you can define the names you want to have and to be able to display them just use a if($column_name == ‘my_column’) { conditional.