0

I am trying to get the list of a specific user type and order them by their registration date.

I searched for ways to do it from here https://codex.wordpress.org/Class_Reference/WP_User_Query#Order_.26_Orderby_Parameters to several Stackoverflow posts but nothing worked so far.

Could you check my code and tell me what's wrong?

$args_tilisateur = array(
'role' => 'coureur',
    'orderby ' => 'registered',
    'order' => 'ASC'

); $usi = new WP_User_Query( $args_tilisateur );

Then to display I do :

if ( !empty($usi->results) ) {
foreach ( $usi->results as $ut ):
    $user_id = $ut->ID;
    $user_info = get_userdata((int)$user_id);

And so on with echoing the values from $user_info.

4
  • try "user_registered" May 3, 2017 at 13:49
  • My bad it was because of the space after orderby ... May 3, 2017 at 13:50
  • Yeah remove that. May 3, 2017 at 13:51
  • thanks for you fast comment though :) May 3, 2017 at 13:53

1 Answer 1

0

My bad, it was only because of the extra space after orderby in the array :

$args_tilisateur = array(
'role' => 'coureur',
'orderby' => 'registered',
'order' => 'ASC');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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