"Created By" Column in the Network Sites List
Records which user created each new site and shows it in a column in Network Admin > Sites, which helps on networks where staff or customers create their own sites.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
add_action( 'wp_initialize_site', function ( $site, $args ) {
$user_id = ! empty( $args['user_id'] ) ? (int) $args['user_id'] : get_current_user_id();
if ( $user_id ) {
update_site_meta( $site->blog_id, 'wpide_created_by', $user_id );
}
}, 300, 2 );
if ( ! is_admin() ) {
return;
}
add_filter( 'wpmu_blogs_columns', function ( $columns ) {
$columns['wpide_created_by'] = __( 'Created by' );
return $columns;
} );
add_action( 'manage_sites_custom_column', function ( $column, $blog_id ) {
if ( 'wpide_created_by' !== $column ) {
return;
}
$user = get_userdata( (int) get_site_meta( $blog_id, 'wpide_created_by', true ) );
if ( $user ) {
printf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'user-edit.php?user_id=' . (int) $user->ID ) ), esc_html( $user->user_login ) );
} else {
echo '—';
}
}, 10, 2 );
Notes
Only sites created after activation are recorded; earlier ones show a dash.
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.