# List a User's Sites on Their Profile

> Shows super admins every site a user belongs to, with their role on each, at the bottom of the user's profile screen.

- Type: PHP
- Runs: Admin only
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: network-admin, users, profile, roles
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-users-sites-on-profile/

## Code

```php
if ( ! is_multisite() ) {
    return;
}

$wpide_user_sites = function ( $user ) {
    if ( ! is_super_admin() ) {
        return;
    }

    $blogs = get_blogs_of_user( $user->ID );
    ?>
    <h2><?php esc_html_e( 'Sites' ); ?></h2>
    <table class="widefat striped" style="max-width:720px">
        <thead><tr><th><?php esc_html_e( 'Site' ); ?></th><th><?php esc_html_e( 'Role' ); ?></th></tr></thead>
        <tbody>
        <?php if ( ! $blogs ) : ?>
            <tr><td colspan="2"><?php esc_html_e( 'This user does not belong to any site.' ); ?></td></tr>
        <?php endif; ?>
        <?php foreach ( $blogs as $blog ) :
            $caps  = get_user_meta( $user->ID, $GLOBALS['wpdb']->get_blog_prefix( $blog->userblog_id ) . 'capabilities', true );
            $roles = is_array( $caps ) ? implode( ', ', array_keys( array_filter( $caps ) ) ) : '';
            ?>
            <tr>
                <td><a href="<?php echo esc_url( get_admin_url( $blog->userblog_id ) ); ?>"><?php echo esc_html( $blog->blogname ); ?></a><br><small><?php echo esc_html( $blog->siteurl ); ?></small></td>
                <td><?php echo esc_html( $roles ? $roles : '—' ); ?></td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
    <?php
};

add_action( 'show_user_profile', $wpide_user_sites );
add_action( 'edit_user_profile', $wpide_user_sites );
```

## Notes

Only super admins see the list.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "List a User's Sites on Their Profile" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
