BuddyDev

Search

[Resolved] Members without profile picture

  • Participant
    Level: Enlightened
    Posts: 38
    Granmeh on #28120

    Hey,

    Do you know how could I display only members with a profile picture in the members directory ?

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #28134

    Hi Granmeh,
    Thank you for the question.

    By default BuddyPress does not keep track if a user has uploaded avatar or not(in the database).

    Is there any chance you might be using any of our plugin:-
    1. BuddyPress profile Completion
    2. Or BuddyPress Force Profile Photo
    3. Or BuddyPress Users with uploaded avatar

    If you are using any of these three, these track the avatar in user meta and I can help you with meta query.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 38
    Granmeh on #28136

    Hey there,

    I’m using “BuddyPress Force Profile Photo and I would like to display only users with the meta_value at “1” and meta_key at “_has_avatar” but I’m completely lost for displaying only users with picture in the members directory.

    So your help would be great.

    Laurent

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #28172

    Hi Laurent,
    Thank you for the patience.

    Please add this to your bp-cusotm.php and let me know if it works or not?

    
    
    add_action( 'bp_after_has_members_parse_args', function ( $args ) {
    
    	if ( bp_is_members_directory() ) {
    		$args['meta_key']   = '_has_avatar';
    		$args['meta_value'] = 1;
    	}
    
    	return $args;
    } );
    
    

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 38
    Granmeh on #28180

    It’s working great but I just noticed, there are 2 meta_keys ‘has_avatar’ and ‘_has_avatar’. How can I add it to the $args ?

    Thanks a lot.

    Laurent

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #28188

    Hi Laurent,
    Thank you.

    Currently BuddyPress User query does not support multiple keys or user meta query in other ways.

    I will suggest sticking with one plugin to have only one meta for the presence of avatar.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 38
    Granmeh on #28191

    I did an update of the field “meta_key” in my phpmyadmin, now it’s all good !!!

    Thanks a lot for your help.

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #28201

    Hi Laurent,
    That’s good to know.

    Best Regards
    Brajesh

The topic ‘ [Resolved] Members without profile picture’ is closed to new replies.

This topic is: resolved