• Resolved Kir 2012

    (@kir-2012)


    Hi there

    I’m trying to create a situation where appearing at the top of the member directory as ‘featured’ becomes a paid for thing.

    If I have a custom capability say: ‘is_featured’.
    I could organise for that capability to be available to purchase.

    So what I would then need to do in ultimate member, is make it possible for the page load in a directory to default to sorting those user pages with that capability at the top of the directory…. which I’m guessing you can do in the member directory admin with ‘Sort users by’ and add in the ‘is_featured’?. Is that right? I couldn’t get it working. When I tried to use this the users that didn’t have the capability didn’t appear at all, which isn’t what I want. I don’t want ONLY those with ‘is_featured’ to show in this directory, I just want those with ‘is_featured’ to show at the top and the rest below.

    Then I would need for ‘is_featured’ to appear as a possible filter too in the filters on that member directory page – so that someone using the directory could carry out their search and also filter it buy featured users. I saw the ‘add search filter’ option in the member directory admin but it didn’t seem to do anything, how should I be using it?

    Thanks for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Following.
    Want to do exactly the same thing, where one user role appears highest up the listings. And those users are also displayed randomly.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @makeitbritish @kir-2012

    You must customize the Member Directory query.

    Here’s a code snippet for showing those featured profiles first.

    add_filter("um_prepare_user_query_args","um_custom_prepare_user_query_args", 9999 );
    function um_custom_prepare_user_query_args( $args ) {
    	
    	$args['meta_query'][ ] = array(
    			'relation' => 'OR',
    		   	'featured_clause' => array(
    				'key' => 'is_featured',
    				'value' => '1',
    				'compare' => '='
    		   	),
    		   	array(
    				"key" => 'is_featured',
    				"compare" => "NOT EXISTS"
    		   	)
    	);
    
    	$args['orderby'] = array(
    		'featured_clause' => 'ASC',
    		
    	); 
    	
    	return $args;
    }

    Ensure that profiles have is_featured meta key to make them show as first profiles.

    Let me know if this works for both of you.

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. 🙂

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add custom member directory sorting / search filter’ is closed to new replies.