Member directory: sorting uses without profile image last

hi all,
how to sort the member directory depending on the profile image. the users without a profile image should be the last in the sorting.

I tried some code see below, but I was not successful.

function hide_users_without_photo_($query) {
// Check if it’s the Ultimate Member query
if (isset($query->query_vars[‘um_user_query’]) && $query->query_vars[‘um_user_query’]) {
// Modify the query to exclude users without a profile photo
$query->query_where .= ” AND ID IN (SELECT user_id FROM wp_usermeta WHERE meta_key = ‘profile_photo’ AND meta_value != ”)”;
}
}

add_action(‘pre_user_query’, ‘hide_users_without_photo_’);

https://www.itf-guides.at/mitglieder/?filter_languages_77509=Englisch

The page I need help with: [log in to see the link]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer