Skip Navigation

[Resolved] Display random users with a view

This support ticket is created 4 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 4 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1276775

I am trying to:
follow https://toolset.com/forums/topic/display-random-posts-with-a-view/ to create a random order for users and realised that does not has a random order option.

How do I create a random order for users with a view?

#1276785

Hi, unfortunately WordPress's User Query does not support randomizing the result order the same way a post query does: https://codex.wordpress.org/Class_Reference/WP_User_Query#Order_.26_Orderby_Parameters
Since Views uses WP_User_Query under the hood, there's nothing built in to provide that random ordering. This would require custom code that gets all the User IDs and returns a random one programmatically, or uses SQL to directly query the Users table in the database.

We offer one filter that might be useful here:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_user_post_query
You can use this filter to manipulate the result set produced by the View, before the results are displayed.

A quick search led me to some articles that have some code you might find helpful if you're interested in crafting your own custom solution:
https://www.wpbeginner.com/wp-tutorials/how-to-randomly-display-registered-users-in-wordpress/
https://wordpress.stackexchange.com/questions/127083/displaying-a-random-user-with-a-shortcode

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.