@bubbleck
You can try this code snippet.
The settings required:
1. Crete a dropdown field in UM Forms builder with Meta Key is_featured.
2. Give the dropdown two possible values 0 and 1.
3. Set the field Privacy to Administrator role only.
4. As an Administrator edit a User from frontend and set this field value to 1.
5. Show Members Directory.
add_filter( 'um_prepare_user_query_args', 'um_custom_prepare_user_query_args', 999999 );
function um_custom_prepare_user_query_args( $args ) {
$args['meta_query'][ ] = array(
'relation' => 'OR',
'featured_clause' => array(
'key' => 'is_featured',
'value' => '1',
'compare' => '='
),
'regular_clause' => array(
'key' => 'is_featured',
'value' => '0',
'compare' => '='
),
'newb_clause' => array(
'key' => 'is_featured',
'compare' => 'NOT EXISTS'
)
);
$args['orderby'] = array(
'newb_clause' => 'ASC',
'regular_clause' => 'ASC',
'featured_clause' => 'ASC',
'user_login'
);
return $args;
}
Install the code snippet into your active theme’s functions.php file
or use the “Code Snippets” plugin.
https://ww.wp.xz.cn/plugins/code-snippets/
-
This reply was modified 2 years, 7 months ago by
missveronica.
Thank you, this is really helpful. I hade to change the following lines to DESC instead of ASC to get the featured profiles to go to the top, but it has worked.
'featured_clause' => 'DESC',
'newb_clause' => 'DESC',
Thanks again.