Hi!
This is the best possible way of doing it after the search process is completed, great job. The suggested solution on the linked topic is to randomize within the query, which I still do not recommend, and it may not even work in some cases.
If I may suggest a tiny modification. The code above only affects user results, but it can be generalized to randomize everything returned, like so:
add_filter('asp_results', 'asp_randomize_results', 10, 2);
function asp_randomize_results($results, $search_id) {
$affected_search_ids = array(1, 2, 3); // Search IDs to affect this code on
// ---- DO NOT CHANGE BELOW -----
if ( in_array($search_id, $affected_search_ids) && count($results) > 0 ) {
shuffle($results);
}
return $results;
}
Thank you again for sharing your solution, I really appreciate it!