diff --git a/admin/settings/class-uwp-settings-user-sorting.php b/admin/settings/class-uwp-settings-user-sorting.php index dcb4572a..e97cba39 100644 --- a/admin/settings/class-uwp-settings-user-sorting.php +++ b/admin/settings/class-uwp-settings-user-sorting.php @@ -100,6 +100,13 @@ public function pre_user_query( $vars ) { } } + if ( is_uwp_users_page() && !empty($_GET['uwp_sort_by']) ) { + if ($_GET['uwp_sort_by'] === 'random_asc' || $_GET['uwp_sort_by'] === 'random_desc') { + // Random order + $vars->query_orderby = 'ORDER BY RAND()'; + } + } + return $vars; } @@ -297,6 +304,16 @@ public function available_fields( $form_type ) { 'description' => __( 'Sort alphabetically by last name in ascending order', 'userswp' ), ); + $fields['random'] = array( + 'data_type' => '', + 'field_type' => 'text', + 'site_title' => __( 'Random', 'userswp' ), + 'htmlvar_name' => 'random', + 'field_icon' => 'fa-solid fa-shuffle', + 'sort' => '', + 'description' => __( 'Sort users by random', 'userswp' ) + ); + $fields = apply_filters( 'uwp_add_custom_sort_options', $fields ); ?> diff --git a/readme.txt b/readme.txt index a5eb1810..08f4d308 100644 --- a/readme.txt +++ b/readme.txt @@ -150,6 +150,9 @@ Yes, you can customize it with Elementor, but also with Gutenberg, Divi, Beaver == Changelog == += 1.2.38 - TBD = +* Option to allow user sorting by random - ADDED + = 1.2.37 - 2025-07-17 = * Option to set maximum username length in register form - ADDED * Added a hook to filter main script loading - CHANGED