Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions admin/settings/class-uwp-settings-user-sorting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 );

?>
Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down