最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Wordpress current month users

programmeradmin3浏览0评论

How to display list of current month user in wordpress?

  <?php $blogusers = get_users( array( 'role' => 'game', 'order' => 'DESC', 'number'  => 50) );
    foreach ( $blogusers as $user ) {  ?>

  <p class="cardname--text"><?php echo $user->display_name; ?></p>
  <?php } ?>


How to display list of current month user in wordpress?

  <?php $blogusers = get_users( array( 'role' => 'game', 'order' => 'DESC', 'number'  => 50) );
    foreach ( $blogusers as $user ) {  ?>

  <p class="cardname--text"><?php echo $user->display_name; ?></p>
  <?php } ?>


Share Improve this question edited Apr 2, 2020 at 6:23 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Apr 2, 2020 at 6:22 PoojaPooja 33 bronze badges 2
  • What do you mean by 'current month users'? Most recently joined, most posts, most comments, most logins, most page views, something else? Depending on what you want you might need to add some tracking as not all of these are recorded automatically. – Rup Commented Apr 2, 2020 at 9:27
  • I want to show only Current month registered Users list. For example, Current month is April, so I want to show all the Registered users of current month. – Pooja Commented Apr 2, 2020 at 11:22
Add a comment  | 

1 Answer 1

Reset to default 1

You can use the get_users function with date_query !

$month_users = get_users(array(
    'date_query'        => array(
        array(
            'after' => 'first day of this month',
            'before' => 'last day of this month',
            'inclusive' => true
        ),
    ),
));
if(!empty($month_users))
{
    foreach($month_users as $k => $v)
    {
        echo 'User : '.$v->display_name.'<br>';
    }    
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论