Menu page with list of users

I need a way to create a menu page with a list of all users for administrative purposes. The list will be used by users that don’t have permission or acceses to the “Users” menu page. The page need to have the User ID, Name, Registration Date, Nickname, User Level and User Role for each user

Any idea how to achieve this ? Any reference docs or tutorial is welcome also.

Related posts

Leave a Reply

2 comments

  1. As a plugin all that I can give to you is this.

    <?php
    /*
    Plugin Name: Users Table
    Plugin URI: http://www.exe.ie
    Description: A list of all available users with their ID, Name, Registration Date, Nickname, User Level and User Role
    Version: 1.0
    Author: Daniel Conde
    Author URI: http://www.exe.ie
    License: GPL
    */
    
    add_action('admin_menu', 'my_user_table_menu');
    
    function my_user_table_menu() {
        add_menu_page('Users Table', 'Users Table', '0', 'users_table', 'users_table');
      }
    
    function users_table() {
            global $wpdb; ?>
        <div>
          <h3>Users Table</h3>
          <table class="wp-list-table widefat fixed users">
            <thead>
              <tr>
                <th><b>User ID</b></th>
                <th><b>Name</b></th>
                <th><b>Registered</b></th>
                <th><b>Nickname</b></th>
                <th><b>User Level</b></th>
                <th><b>User Role</b></th>
              </tr>
            </thead>
            <tbody id="the-list" class="list:user"><?php 
              $wp_user_search = $wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID");
              foreach ( $wp_user_search as $userid ) {
                $user_id = (int) $userid->ID;
                $user_info = get_userdata($user_id);
                $formid = $user_info->formid;
                $user = new WP_User( $user_id );
                echo '<tr id="user-'.$user_id.'" class="alternate">';
                echo '<th>' . $user_id . '</th>';
                echo '<th>' . $user_info->display_name . '</th>';
                echo '<th>' . $user_info->user_registered . '</th>';
                echo '<th>' . $user_info->nickname . '</th>';
                echo '<th>' . $user_info->user_level . '</th>';
                echo '<th>'; if ( !empty( $user->roles ) && is_array( $user->roles ) ) { foreach ( $user->roles as $role ) echo $role; } echo '</th>';
                echo '</tr>';
              } ?>
            </tbody>
            <tfoot>
              <tr>
                <th><b>User ID</b></th>
                <th><b>Name</b></th>
                <th><b>Registered</b></th>
                <th><b>Nickname</b></th>
                <th><b>User Level</b></th>
                <th><b>User Role</b></th>
              </tr>
            </tfoot>
          </table>
        </div><?php 
      } ?>
    

    Not a beauty, but it does the job.

    Copy and save as users-table.php , upload to your plugins folder and activate