• Resolved leezozo

    (@leezozo)


    Hi UltimateMembers team, I’m really loving your plugin.

    Is there any way to showcase a members list but only members with a specific value.

    Here’s my situation: I will have a default members list displayed on my site, but on a separate page I want to have all the members that only answered yes to a yes/no question (dropdown) they filled in on their profiles, members that answered no will not be listed on that page. Is this at all possible? Do i need to use a custom PHP snippet or is there an option in the plugin to do so?

    Your help will be HIGHLY appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @leezozo

    You can try following code snippets:

    add_filter( 'um_prepare_user_query_args', function( $query_args, $directory_data ){
    
        $query_args['meta_query'][] = [
            'key' => 'your_meta_key',
            'value' => 'yes',
            'compare' => '='
        ];
    
        return $query_args;
    
    },99,2);

    Please remember to replace meta key and value as per your requirement.

    Thread Starter leezozo

    (@leezozo)

    Thank you Aswin for your prompt response! How can I add this snippet to a specific member directory?

    Thread Starter leezozo

    (@leezozo)

    Thanks again Aswin. I solved my issue. I added a directory id line of code with my unique directory id “989” to the code below. And it works beautifully!

    add_filter( 'um_prepare_user_query_args', function( $query_args, $directory_data ){
    
    	$directory_id = $directory_data['form_id'];
    
        if( 989 !== $directory_id ) return $query_args;
    	
        $query_args['meta_query'][] = [
            'key' => 'prof_reg1',
            'value' => 'yes',
            'compare' => '='
        ];
    
        return $query_args;
    
    },99,2);
    • This reply was modified 1 year, 9 months ago by leezozo.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Member list but only show members with a specific meta key value’ is closed to new replies.