Orderby=random for user loop

Hi !
I would like to order my type=user by random order like this but it doesn’t work :
<Loop type=user role=contributor order=desc orderby=id> <Field name /> </Loop>
Do you have a idea how to do this please ?

Thank you !

Hi @bikloz - The user loop is based on WP_User_Query, which apparently doesn’t support order by random.

You might be able to achieve it in a roundbout way, by gathering user IDs and creating a new List loop from it.

<!-- Create list of user IDs -->
<Set user_ids><Loop type=user role=contributor><Field id><If not last>,</If></Loop></Set>

<Loop items="{Get user_ids}" orderby=random>
  User ID: <Field />
</Loop>

…Well, after writing the above, I see it won’t work because orderby is not supported by the List loop.

OK, I’ll add a new feature request to address this.

1 Like

OK thank you @eliot, let me know when its live :+1: