• dlx

    (@deeluuxe)


    Hello!
    This plugin is cool – thanks for your work! I′d like to use it on a BuddyPress site. Like shown in your banner not all users upload an avatar (I disabled Gravatar) and to much grey default avatars don′t look nice on a page. So an option to show only users who uploaded an avatar would be great.

    Here′s the code to check this for BuddyPress:

    // check for avatar
    function bb_bp_check_avatar( $id_or_email ) {
    
    	$author_id = $id_or_email; //get_post_author_id();
    	$avatar_folder_url = '/wp-content/uploads/avatars/'. $author_id;
    	$avatar_folder_dir = $_SERVER['DOCUMENT_ROOT'] . $avatar_folder_url;
    	$avatar_name = ( 'full' == $type ) ? '-bpfull' : '-bpthumb';
    	$legacy_user_avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1';
    	
    	if ( file_exists( $avatar_folder_dir ) ) {
    		if ( $av_dir = opendir( $avatar_folder_dir ) ) {
    			while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
    				if ( preg_match( "/{$avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_user_avatar_name}/", $avatar_file ) )
    					$avatar_url = $avatar_folder_url . '/' . $avatar_file;
    			}
    		}
    		closedir($av_dir);
    
    		if ( $avatar_url )
    			return $avatar_url;
    	}
    
    	return false;
    }

    Hope this helps to add this feature.

    Best regards,
    Jan

  • The topic ‘List only users who uploaded avatar’ is closed to new replies.