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
1 Answer
Reset to default 1You 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>';
}
}