BuddyDev

Search

[Resolved] Return in bp_members_suggestions_query_args only bp featured members

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

    Hello,

    I have been using the great plugin https://buddydev.com/plugins/bp-featured-members/ and i am trying to set the bp_members_suggestions_query_args return only $args with featured members.

    I have been trying to set the code snippet here https://buddydev.com/support/forums/topic/hide-current-logged-in-user-and-admin/ to give this result but with no luck.

    How can i get only the featured user from $excluded = get_users( array( 'role' => 'subscriber', 'fields' => 'ID' ) ); ?

    I have changed the code

    function buddydev_filter_buddypress_auto_complete_ids( $args ) {
    	$user_ids = isset( $args['include'] ) ? $args['include'] : array();
    
    	if ( $user_ids && ! is_array( $user_ids ) ) {
    		$user_ids = wp_parse_id_list( $user_ids );
    	}
    
    	$included= get_users( array( '_is_featured' => 1, 'fields' => 'ID' ) );
    
    	$args['include'] = array_merge( $included, $user_ids );
    	return $args;
    }
    add_filter( 'bp_members_suggestions_query_args', 'buddydev_filter_buddypress_auto_complete_ids' );

    but doesn’t work.

    Could anyone give me a help on that please?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2934
    Ravi on #37670

    Hello,

    Thank you for posting. Try the following code and let me know if it works or not.

    
    
    /**
     * Modify member suggestion query args
     *
     * @param array $args Suggestion query args.
     *
     * @return mixed
     */
    function buddydev_filter_buddypress_auto_complete_ids( $args ) {
    
    	if ( ! function_exists( 'bp_featured_members' ) ) {
    		return $args;
    	}
    
    	$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 #37672

    Thank you so much Ravi for your help 🙂

    Yes the code worked just fine.

    How can i exlcude from the results the current user, so that he doesn’t have the option to find him self?

    I have tried something like that

    function buddydev_filter_buddypress_auto_complete_ids( $args ) {
    
    	if ( ! function_exists( 'bp_featured_members' ) ) {
    		return $args;
    	}
    	
        if ( is_user_logged_in() ) {
    		$excluded = get_current_user_id();
    	}
    	$args['meta_key'] = '_is_featured';
    
    	return $args;
    }
    
    add_filter( 'bp_members_suggestions_query_args', 'buddydev_filter_buddypress_auto_complete_ids' );
  • Participant
    Level: Enlightened
    Posts: 71
    Lefteris on #37673

    *Note: The current user may be or may not be a featured member, he sould always be exluded from the returned $args

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2934
    Ravi on #37704

    Hello,

    Thank you for the acknowledgment. Please try the following code:

    
    
    function buddydev_filter_buddypress_auto_complete_ids( $args ) {
    
    	if ( ! function_exists( 'bp_featured_members' ) ) {
    		return $args;
    	}
    
    	if ( is_user_logged_in() ) {
    		$args['excluded'] = get_current_user_id();
    	}
    
    	$args['meta_key'] = '_is_featured';
    
    	return $args;
    }
    
    add_filter( 'bp_members_suggestions_query_args', 'buddydev_filter_buddypress_auto_complete_ids' );
    
    

    Do let me know if it works or not.

    Regards
    Ravi

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

    Thank you very much for your help Ravi.

    But this didn’t work. It didn’t excluded the current user from results.
    Any ideas? 🙂

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2934
    Ravi on #37717

    Hello,

    I have mistakenly posted the wrong variable. Replace the following variable

    
    $args['excluded']
    

    to

    
    $args['exclude']
    

    And give it shot and let me know.

    Regards
    Ravi

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

    Yes Ravi.This worked perfect 🙂 thank you for your help.

    Just another very quick general BP question. What would be the correct hook to send a one time confirmation email to the user when his account passed the authentication process(upon registration we send an email with a link, the user authenticate his account and then he can login). Would it be bp_core_activated_user or bp_core_signup_useror something else? We need to send the one time email after the user authenticated (no need to necessary login).

    Thank you for your time

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2934
    Ravi on #37779

    Hello,

    Thank You for the acknowledgment. I am glad that I could help. ‘bp_core_activate_user’ is called only once at the time of account activation. You can also send an email at the first user login attempt. For the first login check please refer to the following link:

    https://buddydev.com/support/forums/topic/code-adjustment/#post-37469

    Regards
    Ravi

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

    Thank you Ravi for all the info and your help.

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

This topic is: resolved