# Newest Users Dashboard Widget

> Shows the most recent registrations on the dashboard with their role and sign-up date.

- Type: PHP
- Runs: Admin only
- Category: [Dashboard](https://wpide.com/library/category/dashboard/)
- Tags: dashboard, widget, users
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/new-users-dashboard-widget/

## Code

```php
add_action( 'wp_dashboard_setup', function () {
    if ( ! current_user_can( 'list_users' ) ) {
        return;
    }

    wp_add_dashboard_widget( 'wpide_new_users', 'Newest Users', function () {
        $users = get_users( array(
            'number'  => 8,
            'orderby' => 'registered',
            'order'   => 'DESC',
        ) );
        $names = wp_roles()->get_names();

        echo '<ul>';
        foreach ( $users as $user ) {
            $role = $user->roles ? reset( $user->roles ) : '';
            printf(
                '<li>%1$s <a href="%2$s">%3$s</a> <span style="color:#646970">%4$s &middot; %5$s ago</span></li>',
                get_avatar( $user->ID, 20, '', '', array( 'extra_attr' => 'style="vertical-align:middle;border-radius:50%"' ) ),
                esc_url( get_edit_user_link( $user->ID ) ),
                esc_html( $user->display_name ),
                esc_html( $role && isset( $names[ $role ] ) ? translate_user_role( $names[ $role ] ) : 'No role' ),
                esc_html( human_time_diff( strtotime( $user->user_registered ), time() ) )
            );
        }
        echo '</ul>';
    } );
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Newest Users Dashboard Widget" 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/
