我如何列出在我的网站上注册的所有用户并进行分页

时间:2013-08-28 作者:Batman

如何列出在我的网站上注册的所有用户。

如果我有300个用户,我只想在一个页面上列出10个,然后在另一个页面上列出接下来的10个。。

我想让用户有一个图像我想列出用户添加的帖子我想列出用户添加的预告片的数量(自定义帖子类型-trailer)(如果我在用户页面上单击它应该得到的数字)我想列出用户添加的子论坛的数量(自定义帖子类型-子论坛)(如果我在用户页面上单击它应该得到的数字)这是我尝试过的,它列出了可以,但如何

<table class="tut">
        <thead>
          <tr>
            <th><b>Poza</b></th>
            <th><b>Name</b></th>
            <th><b>Inregistrat</b></th>
            <th><b>Nume</b></th>
            <th><b>User Level</b></th>
            <th><b>User Role</b></th>
            <th><b>Vezi Profil</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);
                                                $user_picture =  get_avatar($userid->ID, 40);
            $formid = $user_info->formid;
            $user = new WP_User( $user_id );
            echo \'<th>\' . $user_picture .  \'</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 \'<th>\' . $userid->ID . \'</th>\';
                                                echo \'</tr>\';
          } 
                                        ?>
        </tbody>
        <tfoot>
          <tr>
            <th><b>Poza</b></th>
            <th><b>Name</b></th>
            <th><b>Inregistrat</b></th>
            <th><b>Nume</b></th>
            <th><b>User Level</b></th>
            <th><b>User Role</b></th>
            <th><b>Vezi Profil</b></th>
          </tr>
        </tfoot>
      </table>

1 个回复
SO网友:Anjum

使用wp用户查询代替您自己的查询更多信息,请查看codexhere

$user_query = new WP_User_Query($args);

结束