BuddyDev

Search

[Resolved] Return in bp_members_suggestions_query_args only bp featured members

  • Participant
    Level: Enlightened
    Posts: 71
    Lefteris on #38328

    Hello Ravi,

    May i ask another modification on this.
    If the current_user is not a bp_featured_member , return no results at all.

    Thank you for your time

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3018
    Ravi on #38347

    Hello Lefteris,

    Please use the following code and let me know if it works or not.

    
    function buddydev_filter_buddypress_auto_complete_ids( $args ) {
    
    	if ( ! function_exists( 'bp_featured_members' ) ) {
    		return $args;
    	}
    
    	$current_user_id = get_current_user_id();
    
    	if ( $current_user_id && bp_featured_members()->is_featured( $current_user_id ) ) {
    		$args['exclude'] = $current_user_id;
    	} else {
    		$args['include'] = array( 0 );
    	}
    
    	$args['meta_key'] = '_is_featured';
    
    	return $args;
    }
    
    add_filter( 'bp_members_suggestions_query_args', 'buddydev_filter_buddypress_auto_complete_ids' );
    
    

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 71
    Lefteris on #38359

    Thank you so much Ravi for your help.

    It works perfect.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3018
    Ravi on #38363

    Thank you for the acknowledgment. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] Return in bp_members_suggestions_query_args only bp featured members’ is closed to new replies.

This topic is: resolved