Solving a get_user_meta() problem in Multisite

The problem is that the idea of “the user of a specific subdirectory” doesn’t really exist natively in WP. There are sites (“subdirectories”), and there are users, and users can be associated with sites (through Roles and Capabilities), but there is no guarantee of a one-to-one correspondence.

If you are running a network where users have registered for their own blogs, then there’s a good likelihood that you could use the 'primary_blog' usermeta item to get the information you need. Put the following function in a network activated plugin:

function wpse_50705_get_primary_user_for_blog() {
    global $wpdb;
    return $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'primary_blog' AND meta_value = %d", get_current_blog_id() ) );
}

And then, in your template file,

echo get_user_meta( wpse_50705_get_primary_user_for_blog(), 'display_name', true );

This should work in most cases where users each have a single primary blog – no one has more than one, and there’s no blog that more than one user has as a primary blog.