1

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.

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

  • 2
    +1 but for tables I would use the wp-list-table class – Stephen Harris May 9 '12 at 18:45
-1

Just use wp_list_authors() and extend the author archive – usually author.php.
Depending on the capability you show various author details. No need for a plugin or difficult hacks. :)

  • 1
    Well I think in this case you are wrong, Some how I will end up using a plugin for the whole task as it simplifies things rather that modiffy the author.php – user1068410 May 9 '12 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.